@payloadcms/drizzle 3.23.0 → 3.24.0-canary.05013b2
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 +2 -2
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +19 -10
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/postgres/countDistinct.d.ts.map +1 -1
- package/dist/postgres/countDistinct.js +14 -13
- package/dist/postgres/countDistinct.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +4 -2
- package/dist/postgres/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.js +4 -0
- package/dist/postgres/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +2 -1
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +2 -1
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildOrderBy.d.ts +2 -1
- package/dist/queries/buildOrderBy.d.ts.map +1 -1
- package/dist/queries/buildOrderBy.js +2 -1
- package/dist/queries/buildOrderBy.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -1
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +3 -1
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +2 -1
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +27 -14
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts +2 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +3 -1
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/schema/build.d.ts +2 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +2 -1
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/buildRawSchema.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.js +4 -0
- package/dist/schema/buildRawSchema.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +2 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +32 -16
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/transform/read/index.d.ts +2 -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/traverseFields.d.ts +2 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +28 -16
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +2 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +7 -2
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +2 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +8 -3
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts +2 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js +2 -1
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +2 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +25 -14
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts +7 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.js +14 -5
- package/dist/utilities/hasLocalesTable.js.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts +5 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.js +22 -7
- package/dist/utilities/validateExistingBlockIsIdentical.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/traverseFields.ts"],"sourcesContent":["import type { FlattenedField, JoinQuery, SanitizedConfig } from 'payload'\n\nimport { fieldAffectsData, fieldIsVirtual } from 'payload/shared'\n\nimport type { DrizzleAdapter } 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: DrizzleAdapter\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: FlattenedField[]\n /**\n *\n */\n joinQuery?: JoinQuery\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 * Set to a locale if this group of fields is within a localized array or block.\n */\n withinArrayOrBlockLocale?: string\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 joinQuery,\n numbers,\n path,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n\n const formatted = fields.reduce((result, field) => {\n if (fieldIsVirtual(field)) {\n return result\n }\n\n const fieldName = `${fieldPrefix || ''}${field.name}`\n let 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]) {\n arrayResult[row._locale] = []\n }\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.flattenedFields,\n numbers,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale: locale,\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.reduce((acc, 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 if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.flattenedFields,\n numbers,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale,\n }),\n )\n }\n\n return acc\n }, [])\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks') {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n const blocksByPath = blocks[blockFieldPath]\n\n if (Array.isArray(blocksByPath)) {\n if (field.localized) {\n result[field.name] = {}\n\n blocksByPath.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]) {\n result[field.name][row._locale] = []\n }\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.flattenedFields,\n numbers,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale: locale,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n // Add locale-specific index to have a proper blockFieldPath for current locale\n // because blocks can be in the same array for different locales!\n if (withinArrayOrBlockLocale && config.localization) {\n for (const locale of config.localization.localeCodes) {\n let localeIndex = 0\n\n for (let i = 0; i < blocksByPath.length; i++) {\n const row = blocksByPath[i]\n if (row._locale === locale) {\n row._index = localeIndex\n localeIndex++\n }\n }\n }\n }\n\n result[field.name] = blocksByPath.reduce((acc, 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 if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n if (typeof row._index === 'number') {\n i = row._index\n delete row._index\n }\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.flattenedFields,\n numbers,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale,\n }),\n )\n\n return acc\n }\n } else {\n acc.push({})\n }\n\n return acc\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\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]) {\n relationsByLocale[row.locale] = []\n }\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 withinArrayOrBlockLocale,\n })\n }\n return result\n }\n }\n\n if (field.type === 'join') {\n const { limit = field.defaultLimit ?? 10 } =\n joinQuery?.[`${fieldPrefix.replaceAll('_', '.')}${field.name}`] || {}\n\n // raw hasMany results from SQLite\n if (typeof fieldData === 'string') {\n fieldData = JSON.parse(fieldData)\n }\n\n let fieldResult:\n | { docs: unknown[]; hasNextPage: boolean }\n | Record<string, { docs: unknown[]; hasNextPage: boolean }>\n if (Array.isArray(fieldData)) {\n if (field.localized && adapter.payload.config.localization) {\n fieldResult = fieldData.reduce(\n (joinResult, row) => {\n if (typeof row.locale === 'string') {\n joinResult[row.locale].docs.push(row.id)\n }\n\n return joinResult\n },\n\n // initialize with defaults so empty won't be undefined\n adapter.payload.config.localization.localeCodes.reduce((acc, code) => {\n acc[code] = {\n docs: [],\n hasNextPage: false,\n }\n return acc\n }, {}),\n )\n Object.keys(fieldResult).forEach((locale) => {\n fieldResult[locale].hasNextPage = fieldResult[locale].docs.length > limit\n fieldResult[locale].docs = fieldResult[locale].docs.slice(0, limit)\n })\n } else {\n const hasNextPage = limit !== 0 && fieldData.length > limit\n fieldResult = {\n docs: (hasNextPage ? fieldData.slice(0, limit) : fieldData).map(({ id }) => ({\n id,\n })),\n hasNextPage,\n }\n }\n }\n\n result[field.name] = fieldResult\n return result\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) {\n return result\n }\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]) {\n textsByLocale[row.locale] = []\n }\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 withinArrayOrBlockLocale,\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) {\n return result\n }\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]) {\n numbersByLocale[row.locale] = []\n }\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 withinArrayOrBlockLocale,\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]) {\n selectResult[row.locale] = []\n }\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n let selectData = fieldData\n if (withinArrayOrBlockLocale) {\n selectData = selectData.filter(({ locale }) => locale === withinArrayOrBlockLocale)\n }\n result[field.name] = selectData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (field.localized && Array.isArray(table._locales)) {\n if (!table._locales.length && adapter.payload.config.localization) {\n adapter.payload.config.localization.localeCodes.forEach((_locale) =>\n (table._locales as unknown[]).push({ _locale }),\n )\n }\n\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({\n ref: localizedFieldData,\n table: {\n ...table,\n ...localeRow,\n },\n })\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 'date': {\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n break\n }\n\n case 'group':\n case 'tab': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n const groupData = {}\n const locale = table._locale as string\n const refKey = field.localized && locale ? locale : field.name\n\n if (field.localized && locale) {\n delete table._locale\n }\n ref[refKey] = 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.flattenedFields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale: locale || withinArrayOrBlockLocale,\n })\n\n if ('_order' in ref) {\n delete ref._order\n }\n\n return\n }\n\n case 'number': {\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n break\n }\n\n case 'point': {\n if (typeof fieldData === 'string') {\n val = JSON.parse(fieldData)\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 case 'text': {\n if (typeof fieldData === 'string') {\n val = String(fieldData)\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 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":["fieldIsVirtual","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","dataRef","deletions","fieldPrefix","fields","joinQuery","numbers","path","relationships","table","texts","withinArrayOrBlockLocale","sanitizedPath","formatted","reduce","result","field","fieldName","name","fieldData","localizedFieldData","valuesToTransform","push","type","Array","isArray","localized","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","flattenedFields","_order","acc","i","blockFieldPath","blocksByPath","forEach","Object","entries","localizedBlocks","map","block","find","slug","blockType","blockResult","localization","localeCodes","localeIndex","length","_index","relationTo","hasMany","locales","_locales","localeRow","ref","relationPathMatch","defaultLocale","relationsByLocale","relations","limit","defaultLimit","replaceAll","JSON","parse","fieldResult","payload","joinResult","docs","code","hasNextPage","keys","slice","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","selectData","filter","val","Date","toISOString","groupFieldPrefix","groupData","refKey","Number","parseFloat","collections","customIDType","String"],"mappings":"AAEA,SAA2BA,cAAc,QAAQ,iBAAgB;AAKjE,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,qBAAqB,QAAQ,oBAAmB;AA6DzD,iDAAiD;AACjD,kDAAkD;AAClD,OAAO,MAAMC,iBAAiB,CAAoC,EAChEC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,wBAAwB,EACL;IACnB,MAAMC,gBAAgBL,OAAO,GAAGA,KAAK,CAAC,CAAC,GAAGA;IAE1C,MAAMM,YAAYT,OAAOU,MAAM,CAAC,CAACC,QAAQC;QACvC,IAAIvB,eAAeuB,QAAQ;YACzB,OAAOD;QACT;QAEA,MAAME,YAAY,GAAGd,eAAe,KAAKa,MAAME,IAAI,EAAE;QACrD,IAAIC,YAAYV,KAAK,CAACQ,UAAU;QAChC,MAAMG,qBAAqB,CAAC;QAC5B,MAAMC,oBAGA,EAAE;QAER,IAAIlB,aAAa;YACfD,UAAUoB,IAAI,CAAC,IAAM,OAAOb,KAAK,CAACQ,UAAU;QAC9C;QAEA,IAAID,MAAMO,IAAI,KAAK,SAAS;YAC1B,IAAIC,MAAMC,OAAO,CAACN,YAAY;gBAC5B,IAAIH,MAAMU,SAAS,EAAE;oBACnBX,MAAM,CAACC,MAAME,IAAI,CAAC,GAAGC,UAAUL,MAAM,CAAC,CAACa,aAAaC;wBAClD,IAAI,OAAOA,IAAIC,OAAO,KAAK,UAAU;4BACnC,IAAI,CAACF,WAAW,CAACC,IAAIC,OAAO,CAAC,EAAE;gCAC7BF,WAAW,CAACC,IAAIC,OAAO,CAAC,GAAG,EAAE;4BAC/B;4BACA,MAAMC,SAASF,IAAIC,OAAO;4BAC1B,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ts"],"sourcesContent":["import type { FlattenedBlock, FlattenedField, JoinQuery, SanitizedConfig } from 'payload'\n\nimport { fieldIsVirtual, fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { DrizzleAdapter } 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: DrizzleAdapter\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: FlattenedField[]\n /**\n *\n */\n joinQuery?: JoinQuery\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 parentIsLocalized: boolean\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 * Set to a locale if this group of fields is within a localized array or block.\n */\n withinArrayOrBlockLocale?: string\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 joinQuery,\n numbers,\n parentIsLocalized,\n path,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n\n const formatted = fields.reduce((result, field) => {\n if (fieldIsVirtual(field)) {\n return result\n }\n\n const fieldName = `${fieldPrefix || ''}${field.name}`\n let 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 const isLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n if (field.type === 'array') {\n if (Array.isArray(fieldData)) {\n if (isLocalized) {\n result[field.name] = fieldData.reduce((arrayResult, row) => {\n if (typeof row._locale === 'string') {\n if (!arrayResult[row._locale]) {\n arrayResult[row._locale] = []\n }\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.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale: locale,\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.reduce((acc, 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 if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale,\n }),\n )\n }\n\n return acc\n }, [])\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks') {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n const blocksByPath = blocks[blockFieldPath]\n\n if (Array.isArray(blocksByPath)) {\n if (isLocalized) {\n result[field.name] = {}\n\n blocksByPath.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]) {\n result[field.name][row._locale] = []\n }\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 =\n adapter.payload.blocks[row.blockType] ??\n ((field.blockReferences ?? field.blocks).find(\n (block) => typeof block !== 'string' && block.slug === row.blockType,\n ) as FlattenedBlock | undefined)\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.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale: locale,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n // Add locale-specific index to have a proper blockFieldPath for current locale\n // because blocks can be in the same array for different locales!\n if (withinArrayOrBlockLocale && config.localization) {\n for (const locale of config.localization.localeCodes) {\n let localeIndex = 0\n\n for (let i = 0; i < blocksByPath.length; i++) {\n const row = blocksByPath[i]\n if (row._locale === locale) {\n row._index = localeIndex\n localeIndex++\n }\n }\n }\n }\n\n result[field.name] = blocksByPath.reduce((acc, row, i) => {\n delete row._order\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if (typeof row.blockType !== 'string') {\n return acc\n }\n\n const block =\n adapter.payload.blocks[row.blockType] ??\n ((field.blockReferences ?? field.blocks).find(\n (block) => typeof block !== 'string' && block.slug === row.blockType,\n ) as FlattenedBlock | undefined)\n\n if (block) {\n if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n if (typeof row._index === 'number') {\n i = row._index\n delete row._index\n }\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale,\n }),\n )\n\n return acc\n }\n } else {\n acc.push({})\n }\n\n return acc\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 isLocalized &&\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\n if (!relationPathMatch) {\n if ('hasMany' in field && field.hasMany) {\n if (isLocalized && 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 (isLocalized) {\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]) {\n relationsByLocale[row.locale] = []\n }\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 withinArrayOrBlockLocale,\n })\n }\n return result\n }\n }\n\n if (field.type === 'join') {\n const { limit = field.defaultLimit ?? 10 } =\n joinQuery?.[`${fieldPrefix.replaceAll('_', '.')}${field.name}`] || {}\n\n // raw hasMany results from SQLite\n if (typeof fieldData === 'string') {\n fieldData = JSON.parse(fieldData)\n }\n\n let fieldResult:\n | { docs: unknown[]; hasNextPage: boolean }\n | Record<string, { docs: unknown[]; hasNextPage: boolean }>\n if (Array.isArray(fieldData)) {\n if (isLocalized && adapter.payload.config.localization) {\n fieldResult = fieldData.reduce(\n (joinResult, row) => {\n if (typeof row.locale === 'string') {\n joinResult[row.locale].docs.push(row.id)\n }\n\n return joinResult\n },\n\n // initialize with defaults so empty won't be undefined\n adapter.payload.config.localization.localeCodes.reduce((acc, code) => {\n acc[code] = {\n docs: [],\n hasNextPage: false,\n }\n return acc\n }, {}),\n )\n Object.keys(fieldResult).forEach((locale) => {\n fieldResult[locale].hasNextPage = fieldResult[locale].docs.length > limit\n fieldResult[locale].docs = fieldResult[locale].docs.slice(0, limit)\n })\n } else {\n const hasNextPage = limit !== 0 && fieldData.length > limit\n fieldResult = {\n docs: (hasNextPage ? fieldData.slice(0, limit) : fieldData).map(({ id }) => ({\n id,\n })),\n hasNextPage,\n }\n }\n }\n\n result[field.name] = fieldResult\n return result\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) {\n return result\n }\n\n if (isLocalized) {\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]) {\n textsByLocale[row.locale] = []\n }\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 withinArrayOrBlockLocale,\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) {\n return result\n }\n\n if (isLocalized) {\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]) {\n numbersByLocale[row.locale] = []\n }\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 withinArrayOrBlockLocale,\n })\n }\n\n return result\n }\n\n if (field.type === 'select' && field.hasMany) {\n if (Array.isArray(fieldData)) {\n if (isLocalized) {\n result[field.name] = fieldData.reduce((selectResult, row) => {\n if (typeof row.locale === 'string') {\n if (!selectResult[row.locale]) {\n selectResult[row.locale] = []\n }\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n let selectData = fieldData\n if (withinArrayOrBlockLocale) {\n selectData = selectData.filter(({ locale }) => locale === withinArrayOrBlockLocale)\n }\n result[field.name] = selectData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (isLocalized && Array.isArray(table._locales)) {\n if (!table._locales.length && adapter.payload.config.localization) {\n adapter.payload.config.localization.localeCodes.forEach((_locale) =>\n (table._locales as unknown[]).push({ _locale }),\n )\n }\n\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({\n ref: localizedFieldData,\n table: {\n ...table,\n ...localeRow,\n },\n })\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 'date': {\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n break\n }\n\n case 'group':\n case 'tab': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n const groupData = {}\n const locale = table._locale as string\n const refKey = isLocalized && locale ? locale : field.name\n\n if (isLocalized && locale) {\n delete table._locale\n }\n ref[refKey] = 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.flattenedFields,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale: locale || withinArrayOrBlockLocale,\n })\n\n if ('_order' in ref) {\n delete ref._order\n }\n\n return\n }\n\n case 'number': {\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n break\n }\n\n case 'point': {\n if (typeof fieldData === 'string') {\n val = JSON.parse(fieldData)\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 case 'text': {\n if (typeof fieldData === 'string') {\n val = String(fieldData)\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 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":["fieldIsVirtual","fieldShouldBeLocalized","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","dataRef","deletions","fieldPrefix","fields","joinQuery","numbers","parentIsLocalized","path","relationships","table","texts","withinArrayOrBlockLocale","sanitizedPath","formatted","reduce","result","field","fieldName","name","fieldData","localizedFieldData","valuesToTransform","push","isLocalized","type","Array","isArray","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","flattenedFields","localized","_order","acc","i","blockFieldPath","blocksByPath","forEach","Object","entries","localizedBlocks","map","block","payload","blockType","blockReferences","find","slug","blockResult","localization","localeCodes","localeIndex","length","_index","relationTo","hasMany","locales","_locales","localeRow","ref","relationPathMatch","defaultLocale","relationsByLocale","relations","limit","defaultLimit","replaceAll","JSON","parse","fieldResult","joinResult","docs","code","hasNextPage","keys","slice","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","selectData","filter","val","Date","toISOString","groupFieldPrefix","groupData","refKey","Number","parseFloat","collections","customIDType","String"],"mappings":"AAEA,SAASA,cAAc,EAAEC,sBAAsB,QAAQ,iBAAgB;AAKvE,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,qBAAqB,QAAQ,oBAAmB;AA8DzD,iDAAiD;AACjD,kDAAkD;AAClD,OAAO,MAAMC,iBAAiB,CAAoC,EAChEC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,iBAAiB,EACjBC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,wBAAwB,EACL;IACnB,MAAMC,gBAAgBL,OAAO,GAAGA,KAAK,CAAC,CAAC,GAAGA;IAE1C,MAAMM,YAAYV,OAAOW,MAAM,CAAC,CAACC,QAAQC;QACvC,IAAIzB,eAAeyB,QAAQ;YACzB,OAAOD;QACT;QAEA,MAAME,YAAY,GAAGf,eAAe,KAAKc,MAAME,IAAI,EAAE;QACrD,IAAIC,YAAYV,KAAK,CAACQ,UAAU;QAChC,MAAMG,qBAAqB,CAAC;QAC5B,MAAMC,oBAGA,EAAE;QAER,IAAInB,aAAa;YACfD,UAAUqB,IAAI,CAAC,IAAM,OAAOb,KAAK,CAACQ,UAAU;QAC9C;QAEA,MAAMM,cAAc/B,uBAAuB;YAAEwB;YAAOV;QAAkB;QAEtE,IAAIU,MAAMQ,IAAI,KAAK,SAAS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D,QAAQmD,OAAO,CAACmD,WAAW,CAACnF,MAAM2C,UAAU,CAAC,CAACyC,YAAY,KAAK,UAC/D;4BACAT,MAAMM,OAAON;wBACf;wBAEA;oBACF;gBACA,KAAK;oBAAQ;wBACX,IAAI,OAAOxE,cAAc,UAAU;4BACjCwE,MAAMU,OAAOlF;wBACf;wBAEA;oBACF;gBAEA;oBAAS;wBACP;oBACF;YACF;YACA,IAAI,OAAOW,WAAW,UAAU;gBAC9BkC,GAAG,CAAClC,OAAO,GAAG6D;YAChB,OAAO;gBACL5E,MAAM,CAACC,MAAME,IAAI,CAAC,GAAGyE;YACvB;QACF;QAEA,IAAIhD,OAAOoC,IAAI,CAAC3D,oBAAoBqC,MAAM,GAAG,GAAG;YAC9C1C,MAAM,CAACC,MAAME,IAAI,CAAC,GAAGE;QACvB;QAEA,OAAOL;QAEP,OAAOA;IACT,GAAGf;IAEH,IAAIyB,MAAMC,OAAO,CAACjB,MAAMqD,QAAQ,GAAG;QACjC7D,UAAUqB,IAAI,CAAC,IAAM,OAAOb,MAAMqD,QAAQ;IAC5C;IAEA,OAAOjD;AACT,EAAC"}
|
|
@@ -13,6 +13,7 @@ type Args = {
|
|
|
13
13
|
field: FlattenedArrayField;
|
|
14
14
|
locale?: string;
|
|
15
15
|
numbers: Record<string, unknown>[];
|
|
16
|
+
parentIsLocalized: boolean;
|
|
16
17
|
path: string;
|
|
17
18
|
relationships: Record<string, unknown>[];
|
|
18
19
|
relationshipsToDelete: RelationshipToDelete[];
|
|
@@ -26,6 +27,6 @@ type Args = {
|
|
|
26
27
|
*/
|
|
27
28
|
withinArrayOrBlockLocale?: string;
|
|
28
29
|
};
|
|
29
|
-
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale, }: Args) => ArrayRowToInsert[];
|
|
30
|
+
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale, }: Args) => ArrayRowToInsert[];
|
|
30
31
|
export {};
|
|
31
32
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/transform/write/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/transform/write/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAK1F,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,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,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,mBAAmB,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,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;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,cAAc,+MAiBxB,IAAI,uBAoEN,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { fieldShouldBeLocalized } from 'payload/shared';
|
|
1
2
|
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
|
2
3
|
import { traverseFields } from './traverseFields.js';
|
|
3
|
-
export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale })=>{
|
|
4
|
+
export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale })=>{
|
|
4
5
|
const newRows = [];
|
|
5
6
|
const hasUUID = adapter.tables[arrayTableName]._uuid;
|
|
6
7
|
if (isArrayOfRows(data)) {
|
|
@@ -26,7 +27,10 @@ export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks,
|
|
|
26
27
|
_locale: locale
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
if (
|
|
30
|
+
if (fieldShouldBeLocalized({
|
|
31
|
+
field,
|
|
32
|
+
parentIsLocalized
|
|
33
|
+
}) && locale) {
|
|
30
34
|
newRow.row._locale = locale;
|
|
31
35
|
}
|
|
32
36
|
if (withinArrayOrBlockLocale) {
|
|
@@ -45,6 +49,7 @@ export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks,
|
|
|
45
49
|
insideArrayOrBlock: true,
|
|
46
50
|
locales: newRow.locales,
|
|
47
51
|
numbers,
|
|
52
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
48
53
|
parentTableName: arrayTableName,
|
|
49
54
|
path: `${path || ''}${field.name}.${i}.`,
|
|
50
55
|
relationships,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/array.ts"],"sourcesContent":["import type { FlattenedArrayField } from 'payload'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n arrayTableName: string\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n data: unknown\n field: FlattenedArrayField\n locale?: string\n numbers: Record<string, unknown>[]\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\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 transformArray = ({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n withinArrayOrBlockLocale,\n}: Args) => {\n const newRows: ArrayRowToInsert[] = []\n\n const hasUUID = adapter.tables[arrayTableName]._uuid\n\n if (isArrayOfRows(data)) {\n data.forEach((arrayRow, i) => {\n const newRow: ArrayRowToInsert = {\n arrays: {},\n locales: {},\n row: {\n _order: i + 1,\n },\n }\n\n // If we have declared a _uuid field on arrays,\n // that means the ID has to be unique,\n // and our ids within arrays are not unique.\n // So move the ID to a uuid field for storage\n // and allow the database to generate a serial id automatically\n if (hasUUID) {\n newRow.row._uuid = arrayRow.id\n delete arrayRow.id\n }\n\n if (locale) {\n newRow.locales[locale] = {\n _locale: locale,\n }\n }\n\n if (field
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/array.ts"],"sourcesContent":["import type { FlattenedArrayField } from 'payload'\n\nimport { fieldShouldBeLocalized } from 'payload/shared'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n arrayTableName: string\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n data: unknown\n field: FlattenedArrayField\n locale?: string\n numbers: Record<string, unknown>[]\n parentIsLocalized: boolean\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\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 transformArray = ({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n parentIsLocalized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n withinArrayOrBlockLocale,\n}: Args) => {\n const newRows: ArrayRowToInsert[] = []\n\n const hasUUID = adapter.tables[arrayTableName]._uuid\n\n if (isArrayOfRows(data)) {\n data.forEach((arrayRow, i) => {\n const newRow: ArrayRowToInsert = {\n arrays: {},\n locales: {},\n row: {\n _order: i + 1,\n },\n }\n\n // If we have declared a _uuid field on arrays,\n // that means the ID has to be unique,\n // and our ids within arrays are not unique.\n // So move the ID to a uuid field for storage\n // and allow the database to generate a serial id automatically\n if (hasUUID) {\n newRow.row._uuid = arrayRow.id\n delete arrayRow.id\n }\n\n if (locale) {\n newRow.locales[locale] = {\n _locale: locale,\n }\n }\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && locale) {\n newRow.row._locale = locale\n }\n\n if (withinArrayOrBlockLocale) {\n newRow.row._locale = withinArrayOrBlockLocale\n }\n\n traverseFields({\n adapter,\n arrays: newRow.arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: '',\n data: arrayRow,\n fieldPrefix: '',\n fields: field.flattenedFields,\n insideArrayOrBlock: true,\n locales: newRow.locales,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName: arrayTableName,\n path: `${path || ''}${field.name}.${i}.`,\n relationships,\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n withinArrayOrBlockLocale,\n })\n\n newRows.push(newRow)\n })\n }\n\n return newRows\n}\n"],"names":["fieldShouldBeLocalized","isArrayOfRows","traverseFields","transformArray","adapter","arrayTableName","baseTableName","blocks","blocksToDelete","data","field","locale","numbers","parentIsLocalized","path","relationships","relationshipsToDelete","selects","texts","withinArrayOrBlockLocale","newRows","hasUUID","tables","_uuid","forEach","arrayRow","i","newRow","arrays","locales","row","_order","id","_locale","columnPrefix","fieldPrefix","fields","flattenedFields","insideArrayOrBlock","localized","parentTableName","name","push"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,iBAAgB;AAKvD,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AA6BpD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,iBAAiB,EACjBC,IAAI,EACJC,aAAa,EACbC,qBAAqB,EACrBC,OAAO,EACPC,KAAK,EACLC,wBAAwB,EACnB;IACL,MAAMC,UAA8B,EAAE;IAEtC,MAAMC,UAAUjB,QAAQkB,MAAM,CAACjB,eAAe,CAACkB,KAAK;IAEpD,IAAItB,cAAcQ,OAAO;QACvBA,KAAKe,OAAO,CAAC,CAACC,UAAUC;YACtB,MAAMC,SAA2B;gBAC/BC,QAAQ,CAAC;gBACTC,SAAS,CAAC;gBACVC,KAAK;oBACHC,QAAQL,IAAI;gBACd;YACF;YAEA,+CAA+C;YAC/C,sCAAsC;YACtC,4CAA4C;YAC5C,6CAA6C;YAC7C,+DAA+D;YAC/D,IAAIL,SAAS;gBACXM,OAAOG,GAAG,CAACP,KAAK,GAAGE,SAASO,EAAE;gBAC9B,OAAOP,SAASO,EAAE;YACpB;YAEA,IAAIrB,QAAQ;gBACVgB,OAAOE,OAAO,CAAClB,OAAO,GAAG;oBACvBsB,SAAStB;gBACX;YACF;YAEA,IAAIX,uBAAuB;gBAAEU;gBAAOG;YAAkB,MAAMF,QAAQ;gBAClEgB,OAAOG,GAAG,CAACG,OAAO,GAAGtB;YACvB;YAEA,IAAIQ,0BAA0B;gBAC5BQ,OAAOG,GAAG,CAACG,OAAO,GAAGd;YACvB;YAEAjB,eAAe;gBACbE;gBACAwB,QAAQD,OAAOC,MAAM;gBACrBtB;gBACAC;gBACAC;gBACA0B,cAAc;gBACdzB,MAAMgB;gBACNU,aAAa;gBACbC,QAAQ1B,MAAM2B,eAAe;gBAC7BC,oBAAoB;gBACpBT,SAASF,OAAOE,OAAO;gBACvBjB;gBACAC,mBAAmBA,qBAAqBH,MAAM6B,SAAS;gBACvDC,iBAAiBnC;gBACjBS,MAAM,GAAGA,QAAQ,KAAKJ,MAAM+B,IAAI,CAAC,CAAC,EAAEf,EAAE,CAAC,CAAC;gBACxCX;gBACAC;gBACAc,KAAKH,OAAOG,GAAG;gBACfb;gBACAC;gBACAC;YACF;YAEAC,QAAQsB,IAAI,CAACf;QACf;IACF;IAEA,OAAOP;AACT,EAAC"}
|
|
@@ -12,6 +12,7 @@ type Args = {
|
|
|
12
12
|
field: FlattenedBlocksField;
|
|
13
13
|
locale?: string;
|
|
14
14
|
numbers: Record<string, unknown>[];
|
|
15
|
+
parentIsLocalized: boolean;
|
|
15
16
|
path: string;
|
|
16
17
|
relationships: Record<string, unknown>[];
|
|
17
18
|
relationshipsToDelete: RelationshipToDelete[];
|
|
@@ -25,6 +26,6 @@ type Args = {
|
|
|
25
26
|
*/
|
|
26
27
|
withinArrayOrBlockLocale?: string;
|
|
27
28
|
};
|
|
28
|
-
export declare const transformBlocks: ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale, }: Args) => void;
|
|
29
|
+
export declare const transformBlocks: ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale, }: Args) => void;
|
|
29
30
|
export {};
|
|
30
31
|
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/transform/write/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/transform/write/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAIxE,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,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,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B,KAAK,EAAE,oBAAoB,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,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;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AACD,eAAO,MAAM,eAAe,+LAgBzB,IAAI,SA6EN,CAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { fieldShouldBeLocalized } from 'payload/shared';
|
|
1
2
|
import toSnakeCase from 'to-snake-case';
|
|
2
3
|
import { traverseFields } from './traverseFields.js';
|
|
3
|
-
export const transformBlocks = ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale })=>{
|
|
4
|
+
export const transformBlocks = ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale })=>{
|
|
4
5
|
data.forEach((blockRow, i)=>{
|
|
5
6
|
if (typeof blockRow.blockType !== 'string') {
|
|
6
7
|
return;
|
|
7
8
|
}
|
|
8
|
-
const matchedBlock = field.blocks.find((
|
|
9
|
+
const matchedBlock = adapter.payload.blocks[blockRow.blockType] ?? (field.blockReferences ?? field.blocks).find((block)=>typeof block !== 'string' && block.slug === blockRow.blockType);
|
|
9
10
|
if (!matchedBlock) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
@@ -21,7 +22,10 @@ export const transformBlocks = ({ adapter, baseTableName, blocks, blocksToDelete
|
|
|
21
22
|
_path: `${path}${field.name}`
|
|
22
23
|
}
|
|
23
24
|
};
|
|
24
|
-
if (
|
|
25
|
+
if (fieldShouldBeLocalized({
|
|
26
|
+
field,
|
|
27
|
+
parentIsLocalized
|
|
28
|
+
}) && locale) {
|
|
25
29
|
newRow.row._locale = locale;
|
|
26
30
|
}
|
|
27
31
|
if (withinArrayOrBlockLocale) {
|
|
@@ -51,6 +55,7 @@ export const transformBlocks = ({ adapter, baseTableName, blocks, blocksToDelete
|
|
|
51
55
|
insideArrayOrBlock: true,
|
|
52
56
|
locales: newRow.locales,
|
|
53
57
|
numbers,
|
|
58
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
54
59
|
parentTableName: blockTableName,
|
|
55
60
|
path: `${path || ''}${field.name}.${i}.`,
|
|
56
61
|
relationships,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/blocks.ts"],"sourcesContent":["import type { FlattenedBlocksField } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n data: Record<string, unknown>[]\n field: FlattenedBlocksField\n locale?: string\n numbers: Record<string, unknown>[]\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\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}\nexport const transformBlocks = ({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n withinArrayOrBlockLocale,\n}: Args) => {\n data.forEach((blockRow, i) => {\n if (typeof blockRow.blockType !== 'string') {\n return\n }\n const matchedBlock
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/blocks.ts"],"sourcesContent":["import type { FlattenedBlock, FlattenedBlocksField } from 'payload'\n\nimport { fieldShouldBeLocalized } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n data: Record<string, unknown>[]\n field: FlattenedBlocksField\n locale?: string\n numbers: Record<string, unknown>[]\n parentIsLocalized: boolean\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\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}\nexport const transformBlocks = ({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n parentIsLocalized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n withinArrayOrBlockLocale,\n}: Args) => {\n data.forEach((blockRow, i) => {\n if (typeof blockRow.blockType !== 'string') {\n return\n }\n\n const matchedBlock =\n adapter.payload.blocks[blockRow.blockType] ??\n ((field.blockReferences ?? field.blocks).find(\n (block) => typeof block !== 'string' && block.slug === blockRow.blockType,\n ) as FlattenedBlock | undefined)\n\n if (!matchedBlock) {\n return\n }\n const blockType = toSnakeCase(blockRow.blockType)\n\n if (!blocks[blockType]) {\n blocks[blockType] = []\n }\n\n const newRow: BlockRowToInsert = {\n arrays: {},\n locales: {},\n row: {\n _order: i + 1,\n _path: `${path}${field.name}`,\n },\n }\n\n if (fieldShouldBeLocalized({ field, parentIsLocalized }) && locale) {\n newRow.row._locale = locale\n }\n if (withinArrayOrBlockLocale) {\n newRow.row._locale = withinArrayOrBlockLocale\n }\n\n const blockTableName = adapter.tableNameMap.get(`${baseTableName}_blocks_${blockType}`)\n\n const hasUUID = adapter.tables[blockTableName]._uuid\n\n // If we have declared a _uuid field on arrays,\n // that means the ID has to be unique,\n // and our ids within arrays are not unique.\n // So move the ID to a uuid field for storage\n // and allow the database to generate a serial id automatically\n if (hasUUID) {\n newRow.row._uuid = blockRow.id\n delete blockRow.id\n }\n\n traverseFields({\n adapter,\n arrays: newRow.arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: '',\n data: blockRow,\n fieldPrefix: '',\n fields: matchedBlock.flattenedFields,\n insideArrayOrBlock: true,\n locales: newRow.locales,\n numbers,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName: blockTableName,\n path: `${path || ''}${field.name}.${i}.`,\n relationships,\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n withinArrayOrBlockLocale,\n })\n\n blocks[blockType].push(newRow)\n })\n}\n"],"names":["fieldShouldBeLocalized","toSnakeCase","traverseFields","transformBlocks","adapter","baseTableName","blocks","blocksToDelete","data","field","locale","numbers","parentIsLocalized","path","relationships","relationshipsToDelete","selects","texts","withinArrayOrBlockLocale","forEach","blockRow","i","blockType","matchedBlock","payload","blockReferences","find","block","slug","newRow","arrays","locales","row","_order","_path","name","_locale","blockTableName","tableNameMap","get","hasUUID","tables","_uuid","id","columnPrefix","fieldPrefix","fields","flattenedFields","insideArrayOrBlock","localized","parentTableName","push"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,cAAc,QAAQ,sBAAqB;AA2BpD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,OAAO,EACPC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,iBAAiB,EACjBC,IAAI,EACJC,aAAa,EACbC,qBAAqB,EACrBC,OAAO,EACPC,KAAK,EACLC,wBAAwB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YACAqC,cAAc;YACdpC,MAAMY;YACNyB,aAAa;YACbC,QAAQvB,aAAawB,eAAe;YACpCC,oBAAoB;YACpBjB,SAASF,OAAOE,OAAO;YACvBpB;YACAC,mBAAmBA,qBAAqBH,MAAMwC,SAAS;YACvDC,iBAAiBb;YACjBxB,MAAM,GAAGA,QAAQ,KAAKJ,MAAM0B,IAAI,CAAC,CAAC,EAAEd,EAAE,CAAC,CAAC;YACxCP;YACAC;YACAiB,KAAKH,OAAOG,GAAG;YACfhB;YACAC;YACAC;QACF;QAEAZ,MAAM,CAACgB,UAAU,CAAC6B,IAAI,CAACtB;IACzB;AACF,EAAC"}
|
|
@@ -5,9 +5,10 @@ type Args = {
|
|
|
5
5
|
adapter: DrizzleAdapter;
|
|
6
6
|
data: Record<string, unknown>;
|
|
7
7
|
fields: FlattenedField[];
|
|
8
|
+
parentIsLocalized?: boolean;
|
|
8
9
|
path?: string;
|
|
9
10
|
tableName: string;
|
|
10
11
|
};
|
|
11
|
-
export declare const transformForWrite: ({ adapter, data, fields, path, tableName, }: Args) => RowToInsert;
|
|
12
|
+
export declare const transformForWrite: ({ adapter, data, fields, parentIsLocalized, path, tableName, }: Args) => RowToInsert;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/write/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAI7C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/write/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAI7C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,iBAAiB,mEAO3B,IAAI,KAAG,WAwCT,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { traverseFields } from './traverseFields.js';
|
|
2
|
-
export const transformForWrite = ({ adapter, data, fields, path = '', tableName })=>{
|
|
2
|
+
export const transformForWrite = ({ adapter, data, fields, parentIsLocalized, path = '', tableName })=>{
|
|
3
3
|
// Split out the incoming data into rows to insert / delete
|
|
4
4
|
const rowToInsert = {
|
|
5
5
|
arrays: {},
|
|
@@ -27,6 +27,7 @@ export const transformForWrite = ({ adapter, data, fields, path = '', tableName
|
|
|
27
27
|
fields,
|
|
28
28
|
locales: rowToInsert.locales,
|
|
29
29
|
numbers: rowToInsert.numbers,
|
|
30
|
+
parentIsLocalized,
|
|
30
31
|
parentTableName: tableName,
|
|
31
32
|
path,
|
|
32
33
|
relationships: rowToInsert.relationships,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/index.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { RowToInsert } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n data: Record<string, unknown>\n fields: FlattenedField[]\n path?: string\n tableName: string\n}\n\nexport const transformForWrite = ({\n adapter,\n data,\n fields,\n path = '',\n tableName,\n}: Args): RowToInsert => {\n // Split out the incoming data into rows to insert / delete\n const rowToInsert: RowToInsert = {\n arrays: {},\n blocks: {},\n blocksToDelete: new Set(),\n locales: {},\n numbers: [],\n relationships: [],\n relationshipsToDelete: [],\n row: {},\n selects: {},\n texts: [],\n }\n\n // This function is responsible for building up the\n // above rowToInsert\n traverseFields({\n adapter,\n arrays: rowToInsert.arrays,\n baseTableName: tableName,\n blocks: rowToInsert.blocks,\n blocksToDelete: rowToInsert.blocksToDelete,\n columnPrefix: '',\n data,\n fieldPrefix: '',\n fields,\n locales: rowToInsert.locales,\n numbers: rowToInsert.numbers,\n parentTableName: tableName,\n path,\n relationships: rowToInsert.relationships,\n relationshipsToDelete: rowToInsert.relationshipsToDelete,\n row: rowToInsert.row,\n selects: rowToInsert.selects,\n texts: rowToInsert.texts,\n })\n\n return rowToInsert\n}\n"],"names":["traverseFields","transformForWrite","adapter","data","fields","path","tableName","rowToInsert","arrays","blocks","blocksToDelete","Set","locales","numbers","relationships","relationshipsToDelete","row","selects","texts","baseTableName","columnPrefix","fieldPrefix","parentTableName"],"mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/index.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { RowToInsert } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n data: Record<string, unknown>\n fields: FlattenedField[]\n parentIsLocalized?: boolean\n path?: string\n tableName: string\n}\n\nexport const transformForWrite = ({\n adapter,\n data,\n fields,\n parentIsLocalized,\n path = '',\n tableName,\n}: Args): RowToInsert => {\n // Split out the incoming data into rows to insert / delete\n const rowToInsert: RowToInsert = {\n arrays: {},\n blocks: {},\n blocksToDelete: new Set(),\n locales: {},\n numbers: [],\n relationships: [],\n relationshipsToDelete: [],\n row: {},\n selects: {},\n texts: [],\n }\n\n // This function is responsible for building up the\n // above rowToInsert\n traverseFields({\n adapter,\n arrays: rowToInsert.arrays,\n baseTableName: tableName,\n blocks: rowToInsert.blocks,\n blocksToDelete: rowToInsert.blocksToDelete,\n columnPrefix: '',\n data,\n fieldPrefix: '',\n fields,\n locales: rowToInsert.locales,\n numbers: rowToInsert.numbers,\n parentIsLocalized,\n parentTableName: tableName,\n path,\n relationships: rowToInsert.relationships,\n relationshipsToDelete: rowToInsert.relationshipsToDelete,\n row: rowToInsert.row,\n selects: rowToInsert.selects,\n texts: rowToInsert.texts,\n })\n\n return rowToInsert\n}\n"],"names":["traverseFields","transformForWrite","adapter","data","fields","parentIsLocalized","path","tableName","rowToInsert","arrays","blocks","blocksToDelete","Set","locales","numbers","relationships","relationshipsToDelete","row","selects","texts","baseTableName","columnPrefix","fieldPrefix","parentTableName"],"mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;AAWpD,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,OAAO,EACPC,IAAI,EACJC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EAAE,EACTC,SAAS,EACJ;IACL,2DAA2D;IAC3D,MAAMC,cAA2B;QAC/BC,QAAQ,CAAC;QACTC,QAAQ,CAAC;QACTC,gBAAgB,IAAIC;QACpBC,SAAS,CAAC;QACVC,SAAS,EAAE;QACXC,eAAe,EAAE;QACjBC,uBAAuB,EAAE;QACzBC,KAAK,CAAC;QACNC,SAAS,CAAC;QACVC,OAAO,EAAE;IACX;IAEA,mDAAmD;IACnD,oBAAoB;IACpBnB,eAAe;QACbE;QACAO,QAAQD,YAAYC,MAAM;QAC1BW,eAAeb;QACfG,QAAQF,YAAYE,MAAM;QAC1BC,gBAAgBH,YAAYG,cAAc;QAC1CU,cAAc;QACdlB;QACAmB,aAAa;QACblB;QACAS,SAASL,YAAYK,OAAO;QAC5BC,SAASN,YAAYM,OAAO;QAC5BT;QACAkB,iBAAiBhB;QACjBD;QACAS,eAAeP,YAAYO,aAAa;QACxCC,uBAAuBR,YAAYQ,qBAAqB;QACxDC,KAAKT,YAAYS,GAAG;QACpBC,SAASV,YAAYU,OAAO;QAC5BC,OAAOX,YAAYW,KAAK;IAC1B;IAEA,OAAOX;AACT,EAAC"}
|
|
@@ -36,6 +36,7 @@ type Args = {
|
|
|
36
36
|
[locale: string]: Record<string, unknown>;
|
|
37
37
|
};
|
|
38
38
|
numbers: Record<string, unknown>[];
|
|
39
|
+
parentIsLocalized: boolean;
|
|
39
40
|
/**
|
|
40
41
|
* This is the name of the parent table
|
|
41
42
|
*/
|
|
@@ -54,6 +55,6 @@ type Args = {
|
|
|
54
55
|
*/
|
|
55
56
|
withinArrayOrBlockLocale?: string;
|
|
56
57
|
};
|
|
57
|
-
export declare const traverseFields: ({ adapter, arrays, baseTableName, blocks, blocksToDelete, columnPrefix, data, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock, locales, numbers, parentTableName, path, relationships, relationshipsToDelete, row, selects, texts, withinArrayOrBlockLocale, }: Args) => void;
|
|
58
|
+
export declare const traverseFields: ({ adapter, arrays, baseTableName, blocks, blocksToDelete, columnPrefix, data, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock, locales, numbers, parentIsLocalized, parentTableName, path, relationships, relationshipsToDelete, row, selects, texts, withinArrayOrBlockLocale, }: Args) => void;
|
|
58
59
|
export {};
|
|
59
60
|
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/write/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MA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;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,iBAAiB,EAAE,OAAO,CAAA;IAC1B;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,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;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,cAAc,6SAwBxB,IAAI,SAyaN,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sql } from 'drizzle-orm';
|
|
2
|
-
import { fieldIsVirtual } from 'payload/shared';
|
|
2
|
+
import { fieldIsVirtual, fieldShouldBeLocalized } from 'payload/shared';
|
|
3
3
|
import toSnakeCase from 'to-snake-case';
|
|
4
4
|
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
|
5
5
|
import { transformArray } from './array.js';
|
|
@@ -8,7 +8,7 @@ import { transformNumbers } from './numbers.js';
|
|
|
8
8
|
import { transformRelationship } from './relationships.js';
|
|
9
9
|
import { transformSelects } from './selects.js';
|
|
10
10
|
import { transformTexts } from './texts.js';
|
|
11
|
-
export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksToDelete, columnPrefix, data, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock = false, locales, numbers, parentTableName, path, relationships, relationshipsToDelete, row, selects, texts, withinArrayOrBlockLocale })=>{
|
|
11
|
+
export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksToDelete, columnPrefix, data, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock = false, locales, numbers, parentIsLocalized, parentTableName, path, relationships, relationshipsToDelete, row, selects, texts, withinArrayOrBlockLocale })=>{
|
|
12
12
|
if (row._uuid) {
|
|
13
13
|
data._uuid = row._uuid;
|
|
14
14
|
}
|
|
@@ -22,12 +22,16 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
22
22
|
columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`;
|
|
23
23
|
fieldName = `${fieldPrefix || ''}${field.name}`;
|
|
24
24
|
fieldData = data[field.name];
|
|
25
|
+
const isLocalized = fieldShouldBeLocalized({
|
|
26
|
+
field,
|
|
27
|
+
parentIsLocalized
|
|
28
|
+
});
|
|
25
29
|
if (field.type === 'array') {
|
|
26
30
|
const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
|
|
27
31
|
if (!arrays[arrayTableName]) {
|
|
28
32
|
arrays[arrayTableName] = [];
|
|
29
33
|
}
|
|
30
|
-
if (
|
|
34
|
+
if (isLocalized) {
|
|
31
35
|
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
32
36
|
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
33
37
|
if (Array.isArray(localeData)) {
|
|
@@ -41,6 +45,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
41
45
|
field,
|
|
42
46
|
locale: localeKey,
|
|
43
47
|
numbers,
|
|
48
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
44
49
|
path,
|
|
45
50
|
relationships,
|
|
46
51
|
relationshipsToDelete,
|
|
@@ -62,6 +67,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
62
67
|
data: data[field.name],
|
|
63
68
|
field,
|
|
64
69
|
numbers,
|
|
70
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
65
71
|
path,
|
|
66
72
|
relationships,
|
|
67
73
|
relationshipsToDelete,
|
|
@@ -74,10 +80,11 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
74
80
|
return;
|
|
75
81
|
}
|
|
76
82
|
if (field.type === 'blocks') {
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
;
|
|
84
|
+
(field.blockReferences ?? field.blocks).forEach((block)=>{
|
|
85
|
+
blocksToDelete.add(toSnakeCase(typeof block === 'string' ? block : block.slug));
|
|
79
86
|
});
|
|
80
|
-
if (
|
|
87
|
+
if (isLocalized) {
|
|
81
88
|
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
82
89
|
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
83
90
|
if (Array.isArray(localeData)) {
|
|
@@ -90,6 +97,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
90
97
|
field,
|
|
91
98
|
locale: localeKey,
|
|
92
99
|
numbers,
|
|
100
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
93
101
|
path,
|
|
94
102
|
relationships,
|
|
95
103
|
relationshipsToDelete,
|
|
@@ -109,6 +117,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
109
117
|
data: fieldData,
|
|
110
118
|
field,
|
|
111
119
|
numbers,
|
|
120
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
112
121
|
path,
|
|
113
122
|
relationships,
|
|
114
123
|
relationshipsToDelete,
|
|
@@ -121,7 +130,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
121
130
|
}
|
|
122
131
|
if (field.type === 'group' || field.type === 'tab') {
|
|
123
132
|
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
124
|
-
if (
|
|
133
|
+
if (isLocalized) {
|
|
125
134
|
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
126
135
|
// preserve array ID if there is
|
|
127
136
|
localeData._uuid = data.id || data._uuid;
|
|
@@ -140,6 +149,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
140
149
|
insideArrayOrBlock,
|
|
141
150
|
locales,
|
|
142
151
|
numbers,
|
|
152
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
143
153
|
parentTableName,
|
|
144
154
|
path: `${path || ''}${field.name}.`,
|
|
145
155
|
relationships,
|
|
@@ -168,6 +178,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
168
178
|
insideArrayOrBlock,
|
|
169
179
|
locales,
|
|
170
180
|
numbers,
|
|
181
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
171
182
|
parentTableName,
|
|
172
183
|
path: `${path || ''}${field.name}.`,
|
|
173
184
|
relationships,
|
|
@@ -183,7 +194,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
183
194
|
}
|
|
184
195
|
if (field.type === 'relationship' || field.type === 'upload') {
|
|
185
196
|
const relationshipPath = `${path || ''}${field.name}`;
|
|
186
|
-
if (
|
|
197
|
+
if (isLocalized && (Array.isArray(field.relationTo) || 'hasMany' in field && field.hasMany)) {
|
|
187
198
|
if (typeof fieldData === 'object') {
|
|
188
199
|
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
189
200
|
if (localeData === null) {
|
|
@@ -223,9 +234,9 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
223
234
|
});
|
|
224
235
|
return;
|
|
225
236
|
} else {
|
|
226
|
-
if (!
|
|
237
|
+
if (!isLocalized && fieldData && typeof fieldData === 'object' && 'id' in fieldData && fieldData?.id) {
|
|
227
238
|
fieldData = fieldData.id;
|
|
228
|
-
} else if (
|
|
239
|
+
} else if (isLocalized) {
|
|
229
240
|
if (typeof fieldData === 'object') {
|
|
230
241
|
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
231
242
|
if (typeof localeData === 'object') {
|
|
@@ -242,7 +253,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
242
253
|
}
|
|
243
254
|
if (field.type === 'text' && field.hasMany) {
|
|
244
255
|
const textPath = `${path || ''}${field.name}`;
|
|
245
|
-
if (
|
|
256
|
+
if (isLocalized) {
|
|
246
257
|
if (typeof fieldData === 'object') {
|
|
247
258
|
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
248
259
|
if (Array.isArray(localeData)) {
|
|
@@ -271,7 +282,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
271
282
|
}
|
|
272
283
|
if (field.type === 'number' && field.hasMany) {
|
|
273
284
|
const numberPath = `${path || ''}${field.name}`;
|
|
274
|
-
if (
|
|
285
|
+
if (isLocalized) {
|
|
275
286
|
if (typeof fieldData === 'object') {
|
|
276
287
|
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
277
288
|
if (Array.isArray(localeData)) {
|
|
@@ -303,7 +314,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
303
314
|
if (!selects[selectTableName]) {
|
|
304
315
|
selects[selectTableName] = [];
|
|
305
316
|
}
|
|
306
|
-
if (
|
|
317
|
+
if (isLocalized) {
|
|
307
318
|
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
308
319
|
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
309
320
|
if (Array.isArray(localeData)) {
|
|
@@ -327,7 +338,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
327
338
|
return;
|
|
328
339
|
}
|
|
329
340
|
const valuesToTransform = [];
|
|
330
|
-
if (
|
|
341
|
+
if (isLocalized) {
|
|
331
342
|
if (typeof fieldData === 'object' && fieldData !== null) {
|
|
332
343
|
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
|
333
344
|
if (!locales[localeKey]) {
|