@payloadcms/drizzle 4.0.0-beta.10 → 4.0.0-beta.11
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/exports/postgres.d.ts +1 -0
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +1 -0
- package/dist/exports/postgres.js.map +1 -1
- package/dist/find/buildPolymorphicJoinWhere.js +1 -1
- package/dist/find/buildPolymorphicJoinWhere.js.map +1 -1
- package/dist/postgres/predefinedMigrations/localize-status/getGeneratedColumnType.d.ts +26 -0
- package/dist/postgres/predefinedMigrations/localize-status/getGeneratedColumnType.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/getGeneratedColumnType.js +61 -0
- package/dist/postgres/predefinedMigrations/localize-status/getGeneratedColumnType.js.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/getMigrationDB.d.ts +13 -0
- package/dist/postgres/predefinedMigrations/localize-status/getMigrationDB.d.ts.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/getMigrationDB.js +17 -0
- package/dist/postgres/predefinedMigrations/localize-status/getMigrationDB.js.map +1 -0
- package/dist/postgres/predefinedMigrations/localize-status/index.d.ts.map +1 -1
- package/dist/postgres/predefinedMigrations/localize-status/index.js +73 -10
- package/dist/postgres/predefinedMigrations/localize-status/index.js.map +1 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +51 -2
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +71 -14
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +3 -2
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +2 -1
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +3 -2
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +2 -1
- 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 +2 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +30 -1
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/transform/write/types.d.ts +10 -0
- package/dist/transform/write/types.d.ts.map +1 -1
- package/dist/transform/write/types.js.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts +6 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +21 -3
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +3 -0
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/utilities/createSchemaGenerator.d.ts.map +1 -1
- package/dist/utilities/createSchemaGenerator.js +17 -1
- package/dist/utilities/createSchemaGenerator.js.map +1 -1
- package/dist/utilities/fitIdentifierLength.d.ts +25 -0
- package/dist/utilities/fitIdentifierLength.d.ts.map +1 -0
- package/dist/utilities/fitIdentifierLength.js +35 -0
- package/dist/utilities/fitIdentifierLength.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/schema/traverseFields.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { InvalidConfiguration } from 'payload'\nimport {\n fieldAffectsData,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n optionIsObject,\n} from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type {\n DrizzleAdapter,\n IDType,\n RawColumn,\n RawForeignKey,\n RawIndex,\n RawRelation,\n RelationMap,\n SetColumnID,\n} from '../types.js'\n\nimport { createTableName } from '../createTableName.js'\nimport { buildIndexName } from '../utilities/buildIndexName.js'\nimport { getArrayRelationName } from '../utilities/getArrayRelationName.js'\nimport { hasLocalesTable } from '../utilities/hasLocalesTable.js'\nimport { isUUIDType } from '../utilities/isUUIDType.js'\nimport {\n InternalBlockTableNameIndex,\n setInternalBlockIndex,\n validateExistingBlockIsIdentical,\n} from '../utilities/validateExistingBlockIsIdentical.js'\nimport { buildTable } from './build.js'\nimport { idToUUID } from './idToUUID.js'\nimport { withDefault } from './withDefault.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n blocksTableNameMap: Record<string, number>\n columnPrefix?: string\n columns: Record<string, RawColumn>\n disableNotNull: boolean\n disableRelsTableUnique?: boolean\n disableUnique?: boolean\n fieldPrefix?: string\n fields: FlattenedField[]\n forceLocalized?: boolean\n indexes: Record<string, RawIndex>\n localesColumns: Record<string, RawColumn>\n localesIndexes: Record<string, RawIndex>\n newTableName: string\n parentIsLocalized: boolean\n parentTableName: string\n relationships: Set<string>\n relationsToBuild: RelationMap\n rootRelationsToBuild?: RelationMap\n rootTableIDColType: IDType\n rootTableName: string\n setColumnID: SetColumnID\n uniqueRelationships: Set<string>\n versions: boolean\n /**\n * Tracks whether or not this table is built\n * from the result of a localized array or block field at some point\n */\n withinLocalizedArrayOrBlock?: boolean\n}\n\ntype Result = {\n hasLocalizedField: boolean\n hasLocalizedManyNumberField: boolean\n hasLocalizedManyTextField: boolean\n hasLocalizedRelationshipField: boolean\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n}\n\nexport const traverseFields = ({\n adapter,\n blocksTableNameMap,\n columnPrefix,\n columns,\n disableNotNull,\n disableRelsTableUnique,\n disableUnique = false,\n fieldPrefix,\n fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentIsLocalized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock,\n}: Args): Result => {\n const throwValidationError = true\n let hasLocalizedField = false\n let hasLocalizedRelationshipField = false\n let hasManyTextField: 'index' | boolean = false\n let hasLocalizedManyTextField = false\n let hasManyNumberField: 'index' | boolean = false\n let hasLocalizedManyNumberField = false\n\n let parentIDColType: IDType = 'integer'\n\n const idColumn = columns.id\n\n if (idColumn && ['numeric', 'text', 'uuid', 'varchar'].includes(idColumn.type)) {\n parentIDColType = idColumn.type as IDType\n }\n\n fields.forEach((field) => {\n if ('name' in field && field.name === 'id') {\n return\n }\n if (fieldIsVirtual(field)) {\n return\n }\n\n let targetTable = columns\n let targetIndexes = indexes\n\n const columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${toSnakeCase(\n field.name,\n )}`\n const fieldName = `${fieldPrefix?.replace('.', '_') || ''}${field.name}`\n\n const isFieldLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n // If field is localized,\n // add the column to the locale table instead of main table\n if (\n adapter.payload.config.localization &&\n (isFieldLocalized || forceLocalized) &&\n field.type !== 'array' &&\n (field.type !== 'blocks' || adapter.blocksAsJSON) &&\n (('hasMany' in field && field.hasMany !== true) || !('hasMany' in field))\n ) {\n hasLocalizedField = true\n targetTable = localesColumns\n targetIndexes = localesIndexes\n }\n\n if (\n (field.unique || field.index || ['relationship', 'upload'].includes(field.type)) &&\n !['array', 'blocks', 'group'].includes(field.type) &&\n !('hasMany' in field && field.hasMany === true) &&\n !('relationTo' in field && Array.isArray(field.relationTo))\n ) {\n const unique = disableUnique !== true && field.unique\n if (unique) {\n const constraintValue = `${fieldPrefix || ''}${field.name}`\n if (!adapter.fieldConstraints?.[rootTableName]) {\n adapter.fieldConstraints[rootTableName] = {}\n }\n adapter.fieldConstraints[rootTableName][`${columnName}_idx`] = constraintValue\n }\n\n const indexName = buildIndexName({ name: `${newTableName}_${columnName}`, adapter })\n\n targetIndexes[indexName] = {\n name: indexName,\n on: isFieldLocalized ? [fieldName, '_locale'] : fieldName,\n unique,\n }\n }\n\n switch (field.type) {\n case 'array': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const arrayTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: parentIDColType,\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: `${arrayTableName}_order_idx`,\n on: ['_order'],\n },\n _parentIDIdx: {\n name: `${arrayTableName}_parent_id_idx`,\n on: '_parentID',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIDFk: {\n name: `${arrayTableName}_parent_id_fk`,\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: `${arrayTableName}_locale_idx`,\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(field.flattenedFields) : field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: arrayTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalized,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\n }\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index') {\n hasManyTextField = subHasManyTextField\n }\n }\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index') {\n hasManyNumberField = subHasManyNumberField\n }\n }\n\n const relationName = getArrayRelationName({\n field,\n path: fieldName,\n tableName: arrayTableName,\n })\n\n relationsToBuild.set(relationName, {\n type: 'many',\n // arrays have their own localized table, independent of the base table.\n localized: false,\n target: arrayTableName,\n })\n\n const arrayRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: arrayTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: parentTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n arrayRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${arrayTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const arrayWithLocalized = localized\n ? `${arrayTableName}${adapter.localesSuffix}`\n : arrayTableName\n\n arrayRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: arrayWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n arrayRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[arrayTableName] = arrayRelations\n\n break\n }\n case 'blocks': {\n if (adapter.blocksAsJSON) {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n break\n }\n\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n field.blocks.forEach((_block) => {\n const block = typeof _block === 'string' ? adapter.payload.blocks[_block] : _block\n\n let blockTableName = createTableName({\n adapter,\n config: block,\n parentTableName: rootTableName,\n prefix: `${rootTableName}_blocks_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const isLocalizedBlockTable =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (typeof blocksTableNameMap[blockTableName] === 'undefined') {\n blocksTableNameMap[blockTableName] = 1\n } else if (\n !adapter.rawTables[blockTableName] ||\n !validateExistingBlockIsIdentical({\n block,\n localized: isLocalizedBlockTable,\n parentIsLocalized,\n table: adapter.rawTables[blockTableName],\n tableLocales: adapter.rawTables[`${blockTableName}${adapter.localesSuffix}`],\n })\n ) {\n blocksTableNameMap[blockTableName]++\n setInternalBlockIndex(block, blocksTableNameMap[blockTableName])\n blockTableName = `${blockTableName}_${blocksTableNameMap[blockTableName]}`\n }\n let relationName = `_blocks_${block.slug}`\n if (typeof block[InternalBlockTableNameIndex] !== 'undefined') {\n relationName = `_blocks_${block.slug}_${block[InternalBlockTableNameIndex]}`\n }\n\n if (!adapter.rawTables[blockTableName]) {\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: rootTableIDColType,\n notNull: true,\n },\n _path: {\n name: '_path',\n type: 'text',\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: `${blockTableName}_order_idx`,\n on: '_order',\n },\n _parentIDIdx: {\n name: `${blockTableName}_parent_id_idx`,\n on: ['_parentID'],\n },\n _pathIdx: {\n name: `${blockTableName}_path_idx`,\n on: '_path',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIdFk: {\n name: `${blockTableName}_parent_id_fk`,\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: rootTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n if (isLocalizedBlockTable) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: `${blockTableName}_locale_idx`,\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(block.flattenedFields) : block.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: blockTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalizedBlockTable,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\n }\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index') {\n hasManyTextField = subHasManyTextField\n }\n }\n\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index') {\n hasManyNumberField = subHasManyNumberField\n }\n }\n\n const blockRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: blockTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: rootTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n blockRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${blockTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const blockWithLocalized = localized\n ? `${blockTableName}${adapter.localesSuffix}`\n : blockTableName\n\n blockRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: blockWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n blockRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[blockTableName] = blockRelations\n }\n\n // blocks relationships are defined from the collection or globals table down to the block, bypassing any subBlocks\n rootRelationsToBuild.set(relationName, {\n type: 'many',\n // blocks are not localized on the parent table\n localized: false,\n target: blockTableName,\n })\n })\n\n break\n }\n case 'checkbox': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'boolean',\n },\n field,\n )\n\n break\n }\n\n case 'code':\n case 'email':\n case 'slug':\n case 'textarea': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n\n break\n }\n\n case 'date': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'timestamp',\n mode: 'string',\n precision: 3,\n withTimezone: true,\n },\n field,\n )\n\n break\n }\n\n case 'group':\n case 'tab': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const {\n hasLocalizedField: groupHasLocalizedField,\n hasLocalizedManyNumberField: groupHasLocalizedManyNumberField,\n hasLocalizedManyTextField: groupHasLocalizedManyTextField,\n hasLocalizedRelationshipField: groupHasLocalizedRelationshipField,\n hasManyNumberField: groupHasManyNumberField,\n hasManyTextField: groupHasManyTextField,\n } = traverseFields({\n adapter,\n blocksTableNameMap,\n columnPrefix: `${columnName}_`,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix: `${fieldName}.`,\n fields: field.flattenedFields,\n forceLocalized: isFieldLocalized || Boolean(forceLocalized),\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: `${parentTableName}_${columnName}`,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock: withinLocalizedArrayOrBlock || isFieldLocalized,\n })\n\n if (groupHasLocalizedField) {\n hasLocalizedField = true\n }\n if (groupHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = true\n }\n if (groupHasManyTextField) {\n hasManyTextField = true\n }\n if (groupHasLocalizedManyTextField) {\n hasLocalizedManyTextField = true\n }\n if (groupHasManyNumberField) {\n hasManyNumberField = true\n }\n if (groupHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = true\n }\n break\n }\n\n case 'json':\n case 'richText': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n\n break\n }\n\n case 'number': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n hasLocalizedManyNumberField = true\n }\n\n if (field.index) {\n hasManyNumberField = 'index'\n } else if (!hasManyNumberField) {\n hasManyNumberField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany number fields.',\n )\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'numeric',\n },\n field,\n )\n }\n\n break\n }\n\n case 'point': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'geometry',\n },\n field,\n )\n\n break\n }\n\n case 'radio':\n case 'select': {\n const enumName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n })\n\n const options = field.options.map((option) => {\n if (optionIsObject(option)) {\n return option.value\n }\n\n return option\n })\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n order: {\n name: 'order',\n type: 'integer',\n notNull: true,\n },\n parent: {\n name: 'parent_id',\n type: parentIDColType,\n notNull: true,\n },\n value: {\n name: 'value',\n type: 'enum',\n enumName: createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n }),\n options,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n orderIdx: {\n name: `${selectTableName}_order_idx`,\n on: 'order',\n },\n parentIdx: {\n name: `${selectTableName}_parent_idx`,\n on: 'parent',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n parentFk: {\n name: `${selectTableName}_parent_fk`,\n columns: ['parent'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns.locale = {\n name: 'locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes.localeIdx = {\n name: `${selectTableName}_locale_idx`,\n on: 'locale',\n }\n }\n\n if (field.index) {\n baseIndexes.value = {\n name: `${selectTableName}_value_idx`,\n on: 'value',\n }\n }\n\n buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull,\n disableUnique,\n fields: [],\n parentIsLocalized: parentIsLocalized || field.localized,\n rootTableName,\n setColumnID,\n tableName: selectTableName,\n versions,\n })\n\n relationsToBuild.set(fieldName, {\n type: 'many',\n // selects have their own localized table, independent of the base table.\n localized: false,\n target: selectTableName,\n })\n\n adapter.rawRelations[selectTableName] = {\n parent: {\n type: 'one',\n fields: [\n {\n name: 'parent',\n table: selectTableName,\n },\n ],\n references: ['id'],\n relationName: fieldName,\n to: parentTableName,\n },\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'enum',\n enumName,\n options,\n },\n field,\n )\n }\n break\n }\n\n case 'relationship':\n case 'upload':\n if (Array.isArray(field.relationTo)) {\n field.relationTo.forEach((relation) => {\n relationships.add(relation)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(relation)\n }\n })\n } else if (field.hasMany) {\n relationships.add(field.relationTo)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(field.relationTo)\n }\n } else {\n // simple relationships get a column on the targetTable with a foreign key to the relationTo table\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n const tableName = adapter.tableNameMap.get(toSnakeCase(field.relationTo))\n\n // get the id type of the related collection\n let colType: IDType = isUUIDType(adapter.idType) ? 'uuid' : 'integer'\n const relatedCollectionCustomID = relationshipConfig.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n if (relatedCollectionCustomID?.type === 'number') {\n colType = 'numeric'\n }\n if (relatedCollectionCustomID?.type === 'text') {\n colType = 'varchar'\n }\n\n // make the foreign key column for relationship using the correct id column type\n targetTable[fieldName] = {\n name: `${columnName}_id`,\n type: colType,\n reference: {\n name: 'id',\n onDelete: 'set null',\n table: tableName,\n },\n }\n\n // add relationship to table\n relationsToBuild.set(fieldName, {\n type: 'one',\n localized: adapter.payload.config.localization && (isFieldLocalized || forceLocalized),\n target: tableName,\n })\n\n // add notNull when not required\n if (!disableNotNull && field.required && !field.admin?.condition) {\n targetTable[fieldName].notNull = true\n }\n break\n }\n\n if (\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock\n ) {\n hasLocalizedRelationshipField = true\n }\n\n break\n\n case 'text': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n hasLocalizedManyTextField = true\n }\n\n if (field.index) {\n hasManyTextField = 'index'\n } else if (!hasManyTextField) {\n hasManyTextField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany text fields.',\n )\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n }\n break\n }\n\n default:\n break\n }\n\n const condition = field.admin && field.admin.condition\n\n if (\n !disableNotNull &&\n targetTable[fieldName] &&\n 'required' in field &&\n field.required &&\n !condition\n ) {\n targetTable[fieldName].notNull = true\n }\n })\n\n return {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n }\n}\n"],"names":["InvalidConfiguration","fieldAffectsData","fieldIsVirtual","fieldShouldBeLocalized","optionIsObject","toSnakeCase","createTableName","buildIndexName","getArrayRelationName","hasLocalesTable","isUUIDType","InternalBlockTableNameIndex","setInternalBlockIndex","validateExistingBlockIsIdentical","buildTable","idToUUID","withDefault","traverseFields","adapter","blocksTableNameMap","columnPrefix","columns","disableNotNull","disableRelsTableUnique","disableUnique","fieldPrefix","fields","forceLocalized","indexes","localesColumns","localesIndexes","newTableName","parentIsLocalized","parentTableName","relationships","relationsToBuild","rootRelationsToBuild","rootTableIDColType","rootTableName","setColumnID","uniqueRelationships","versions","withinLocalizedArrayOrBlock","throwValidationError","hasLocalizedField","hasLocalizedRelationshipField","hasManyTextField","hasLocalizedManyTextField","hasManyNumberField","hasLocalizedManyNumberField","parentIDColType","idColumn","id","includes","type","forEach","field","name","targetTable","targetIndexes","columnName","fieldName","replace","isFieldLocalized","payload","config","localization","blocksAsJSON","hasMany","unique","index","Array","isArray","relationTo","constraintValue","fieldConstraints","indexName","on","disableNotNullFromHere","Boolean","admin","condition","arrayTableName","prefix","versionsCustomName","baseColumns","_order","notNull","_parentID","baseIndexes","_orderIdx","_parentIDIdx","baseForeignKeys","_parentIDFk","foreignColumns","table","onDelete","isLocalized","_locale","locale","_localeIdx","subHasLocalizedManyNumberField","subHasLocalizedManyTextField","subHasLocalizedRelationshipField","subHasManyNumberField","subHasManyTextField","subRelationsToBuild","flattenedFields","localized","rootRelationships","rootUniqueRelationships","tableName","relationName","path","set","target","arrayRelations","references","to","_locales","localesSuffix","key","arrayWithLocalized","rawRelations","blocks","_block","block","blockTableName","isLocalizedBlockTable","rawTables","tableLocales","slug","_path","_pathIdx","_parentIdFk","blockRelations","blockWithLocalized","mode","precision","withTimezone","groupHasLocalizedField","groupHasLocalizedManyNumberField","groupHasLocalizedManyTextField","groupHasLocalizedRelationshipField","groupHasManyNumberField","groupHasManyTextField","enumName","options","map","option","value","selectTableName","order","parent","orderIdx","parentIdx","parentFk","localeIdx","relation","add","relationshipConfig","collections","tableNameMap","get","colType","idType","relatedCollectionCustomID","find","reference","required"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAS;AAC9C,SACEC,gBAAgB,EAChBC,cAAc,EACdC,sBAAsB,EACtBC,cAAc,QACT,iBAAgB;AACvB,OAAOC,iBAAiB,gBAAe;AAavC,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,gCAAgC,QAC3B,mDAAkD;AACzD,SAASC,UAAU,QAAQ,aAAY;AACvC,SAASC,QAAQ,QAAQ,gBAAe;AACxC,SAASC,WAAW,QAAQ,mBAAkB;AA2C9C,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EAC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,CAACC,MAAM,CAACC,YAAY,KAC/DxB,6BACA;oBACAG,gCAAgC;gBAClC;gBAEA;YAEF,KAAK;gBAAQ;oBACX,IAAIW,MAAMY,OAAO,EAAE;wBACjB,MAAM6B,cACJlB,QAAQhB,oBAAoB7C,QAAQ8C,OAAO,CAACC,MAAM,CAACC,YAAY,KAC/DxB,+BACAf;wBAEF,IAAIsE,aAAa;4BACflD,4BAA4B;wBAC9B;wBAEA,IAAIS,MAAMc,KAAK,EAAE;4BACfxB,mBAAmB;wBACrB,OAAO,IAAI,CAACA,kBAAkB;4BAC5BA,mBAAmB;wBACrB;wBAEA,IAAIU,MAAMa,MAAM,EAAE;4BAChB,MAAM,IAAIrE,qBACR;wBAEJ;oBACF,OAAO;wBACL0D,WAAW,CAACG,UAAU,GAAG7C,YACvB;4BACEyC,MAAMG;4BACNN,MAAM;wBACR,GACAE;oBAEJ;oBACA;gBACF;YAEA;gBACE;QACJ;QAEA,MAAMyB,YAAYzB,MAAMwB,KAAK,IAAIxB,MAAMwB,KAAK,CAACC,SAAS;QAEtD,IACE,CAAC3D,kBACDoC,WAAW,CAACG,UAAU,IACtB,cAAcL,SACdA,MAAMiH,QAAQ,IACd,CAACxF,WACD;YACAvB,WAAW,CAACG,UAAU,CAAC0B,OAAO,GAAG;QACnC;IACF;IAEA,OAAO;QACL3C;QACAK;QACAF;QACAF;QACAG;QACAF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/schema/traverseFields.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { InvalidConfiguration } from 'payload'\nimport {\n fieldAffectsData,\n fieldIsVirtual,\n fieldShouldBeLocalized,\n optionIsObject,\n} from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type {\n DrizzleAdapter,\n IDType,\n RawColumn,\n RawForeignKey,\n RawIndex,\n RawRelation,\n RelationMap,\n SetColumnID,\n} from '../types.js'\n\nimport { createTableName } from '../createTableName.js'\nimport { buildIndexName } from '../utilities/buildIndexName.js'\nimport { fitIdentifierLength } from '../utilities/fitIdentifierLength.js'\nimport { getArrayRelationName } from '../utilities/getArrayRelationName.js'\nimport { hasLocalesTable } from '../utilities/hasLocalesTable.js'\nimport { isUUIDType } from '../utilities/isUUIDType.js'\nimport {\n InternalBlockTableNameIndex,\n setInternalBlockIndex,\n validateExistingBlockIsIdentical,\n} from '../utilities/validateExistingBlockIsIdentical.js'\nimport { buildTable } from './build.js'\nimport { idToUUID } from './idToUUID.js'\nimport { withDefault } from './withDefault.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n blocksTableNameMap: Record<string, number>\n columnPrefix?: string\n columns: Record<string, RawColumn>\n disableNotNull: boolean\n disableRelsTableUnique?: boolean\n disableUnique?: boolean\n fieldPrefix?: string\n fields: FlattenedField[]\n forceLocalized?: boolean\n indexes: Record<string, RawIndex>\n localesColumns: Record<string, RawColumn>\n localesIndexes: Record<string, RawIndex>\n newTableName: string\n parentIsLocalized: boolean\n parentTableName: string\n relationships: Set<string>\n relationsToBuild: RelationMap\n rootRelationsToBuild?: RelationMap\n rootTableIDColType: IDType\n rootTableName: string\n setColumnID: SetColumnID\n uniqueRelationships: Set<string>\n versions: boolean\n /**\n * Tracks whether or not this table is built\n * from the result of a localized array or block field at some point\n */\n withinLocalizedArrayOrBlock?: boolean\n}\n\ntype Result = {\n hasLocalizedField: boolean\n hasLocalizedManyNumberField: boolean\n hasLocalizedManyTextField: boolean\n hasLocalizedRelationshipField: boolean\n hasManyNumberField: 'index' | boolean\n hasManyTextField: 'index' | boolean\n}\n\nexport const traverseFields = ({\n adapter,\n blocksTableNameMap,\n columnPrefix,\n columns,\n disableNotNull,\n disableRelsTableUnique,\n disableUnique = false,\n fieldPrefix,\n fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentIsLocalized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock,\n}: Args): Result => {\n const throwValidationError = true\n let hasLocalizedField = false\n let hasLocalizedRelationshipField = false\n let hasManyTextField: 'index' | boolean = false\n let hasLocalizedManyTextField = false\n let hasManyNumberField: 'index' | boolean = false\n let hasLocalizedManyNumberField = false\n\n let parentIDColType: IDType = 'integer'\n\n const idColumn = columns.id\n\n if (idColumn && ['numeric', 'text', 'uuid', 'varchar'].includes(idColumn.type)) {\n parentIDColType = idColumn.type as IDType\n }\n\n fields.forEach((field) => {\n if ('name' in field && field.name === 'id') {\n return\n }\n if (fieldIsVirtual(field)) {\n return\n }\n\n let targetTable = columns\n let targetIndexes = indexes\n\n const columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${toSnakeCase(\n field.name,\n )}`\n const fieldName = `${fieldPrefix?.replace('.', '_') || ''}${field.name}`\n\n const isFieldLocalized = fieldShouldBeLocalized({ field, parentIsLocalized })\n\n // If field is localized,\n // add the column to the locale table instead of main table\n if (\n adapter.payload.config.localization &&\n (isFieldLocalized || forceLocalized) &&\n field.type !== 'array' &&\n (field.type !== 'blocks' || adapter.blocksAsJSON) &&\n (('hasMany' in field && field.hasMany !== true) || !('hasMany' in field))\n ) {\n hasLocalizedField = true\n targetTable = localesColumns\n targetIndexes = localesIndexes\n }\n\n if (\n (field.unique || field.index || ['relationship', 'upload'].includes(field.type)) &&\n !['array', 'blocks', 'group'].includes(field.type) &&\n !('hasMany' in field && field.hasMany === true) &&\n !('relationTo' in field && Array.isArray(field.relationTo))\n ) {\n const unique = disableUnique !== true && field.unique\n if (unique) {\n const constraintValue = `${fieldPrefix || ''}${field.name}`\n if (!adapter.fieldConstraints?.[rootTableName]) {\n adapter.fieldConstraints[rootTableName] = {}\n }\n adapter.fieldConstraints[rootTableName][`${columnName}_idx`] = constraintValue\n }\n\n const indexName = buildIndexName({ name: `${newTableName}_${columnName}`, adapter })\n\n targetIndexes[indexName] = {\n name: indexName,\n on: isFieldLocalized ? [fieldName, '_locale'] : fieldName,\n unique,\n }\n }\n\n switch (field.type) {\n case 'array': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const arrayTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: parentIDColType,\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: fitIdentifierLength({ name: `${arrayTableName}_order`, adapter, suffix: '_idx' }),\n on: ['_order'],\n },\n _parentIDIdx: {\n name: fitIdentifierLength({\n name: `${arrayTableName}_parent_id`,\n adapter,\n suffix: '_idx',\n }),\n on: '_parentID',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIDFk: {\n name: fitIdentifierLength({\n name: `${arrayTableName}_parent_id`,\n adapter,\n suffix: '_fk',\n }),\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: fitIdentifierLength({\n name: `${arrayTableName}_locale`,\n adapter,\n suffix: '_idx',\n }),\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(field.flattenedFields) : field.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: arrayTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalized,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\n }\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index') {\n hasManyTextField = subHasManyTextField\n }\n }\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index') {\n hasManyNumberField = subHasManyNumberField\n }\n }\n\n const relationName = getArrayRelationName({\n field,\n path: fieldName,\n tableName: arrayTableName,\n })\n\n relationsToBuild.set(relationName, {\n type: 'many',\n // arrays have their own localized table, independent of the base table.\n localized: false,\n target: arrayTableName,\n })\n\n const arrayRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: arrayTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: parentTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: field.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n arrayRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${arrayTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const arrayWithLocalized = localized\n ? `${arrayTableName}${adapter.localesSuffix}`\n : arrayTableName\n\n arrayRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: arrayWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n arrayRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[arrayTableName] = arrayRelations\n\n break\n }\n case 'blocks': {\n if (adapter.blocksAsJSON) {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n break\n }\n\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n field.blocks.forEach((_block) => {\n const block = typeof _block === 'string' ? adapter.payload.blocks[_block] : _block\n\n let blockTableName = createTableName({\n adapter,\n config: block,\n parentTableName: rootTableName,\n prefix: `${rootTableName}_blocks_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const isLocalizedBlockTable =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (typeof blocksTableNameMap[blockTableName] === 'undefined') {\n blocksTableNameMap[blockTableName] = 1\n } else if (\n !adapter.rawTables[blockTableName] ||\n !validateExistingBlockIsIdentical({\n block,\n localized: isLocalizedBlockTable,\n parentIsLocalized,\n table: adapter.rawTables[blockTableName],\n tableLocales: adapter.rawTables[`${blockTableName}${adapter.localesSuffix}`],\n })\n ) {\n blocksTableNameMap[blockTableName]++\n setInternalBlockIndex(block, blocksTableNameMap[blockTableName])\n blockTableName = `${blockTableName}_${blocksTableNameMap[blockTableName]}`\n }\n let relationName = `_blocks_${block.slug}`\n if (typeof block[InternalBlockTableNameIndex] !== 'undefined') {\n relationName = `_blocks_${block.slug}_${block[InternalBlockTableNameIndex]}`\n }\n\n if (!adapter.rawTables[blockTableName]) {\n const baseColumns: Record<string, RawColumn> = {\n _order: {\n name: '_order',\n type: 'integer',\n notNull: true,\n },\n _parentID: {\n name: '_parent_id',\n type: rootTableIDColType,\n notNull: true,\n },\n _path: {\n name: '_path',\n type: 'text',\n notNull: true,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n _orderIdx: {\n name: fitIdentifierLength({\n name: `${blockTableName}_order`,\n adapter,\n suffix: '_idx',\n }),\n on: '_order',\n },\n _parentIDIdx: {\n name: fitIdentifierLength({\n name: `${blockTableName}_parent_id`,\n adapter,\n suffix: '_idx',\n }),\n on: ['_parentID'],\n },\n _pathIdx: {\n name: fitIdentifierLength({\n name: `${blockTableName}_path`,\n adapter,\n suffix: '_idx',\n }),\n on: '_path',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n _parentIdFk: {\n name: fitIdentifierLength({\n name: `${blockTableName}_parent_id`,\n adapter,\n suffix: '_fk',\n }),\n columns: ['_parentID'],\n foreignColumns: [\n {\n name: 'id',\n table: rootTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n if (isLocalizedBlockTable) {\n baseColumns._locale = {\n name: '_locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes._localeIdx = {\n name: fitIdentifierLength({\n name: `${blockTableName}_locale`,\n adapter,\n suffix: '_idx',\n }),\n on: '_locale',\n }\n }\n\n const {\n hasLocalizedManyNumberField: subHasLocalizedManyNumberField,\n hasLocalizedManyTextField: subHasLocalizedManyTextField,\n hasLocalizedRelationshipField: subHasLocalizedRelationshipField,\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull: disableNotNullFromHere,\n disableRelsTableUnique: true,\n disableUnique,\n fields: disableUnique ? idToUUID(block.flattenedFields) : block.flattenedFields,\n parentIsLocalized: parentIsLocalized || field.localized,\n rootRelationships: relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n rootUniqueRelationships: uniqueRelationships,\n setColumnID,\n tableName: blockTableName,\n versions,\n withinLocalizedArrayOrBlock: isLocalizedBlockTable,\n })\n\n if (subHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = subHasLocalizedManyNumberField\n }\n\n if (subHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = subHasLocalizedRelationshipField\n }\n\n if (subHasLocalizedManyTextField) {\n hasLocalizedManyTextField = subHasLocalizedManyTextField\n }\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index') {\n hasManyTextField = subHasManyTextField\n }\n }\n\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index') {\n hasManyNumberField = subHasManyNumberField\n }\n }\n\n const blockRelations: Record<string, RawRelation> = {\n _parentID: {\n type: 'one',\n fields: [\n {\n name: '_parentID',\n table: blockTableName,\n },\n ],\n references: ['id'],\n relationName,\n to: rootTableName,\n },\n }\n\n if (\n hasLocalesTable({\n fields: block.fields,\n parentIsLocalized: parentIsLocalized || field.localized,\n })\n ) {\n blockRelations._locales = {\n type: 'many',\n relationName: '_locales',\n to: `${blockTableName}${adapter.localesSuffix}`,\n }\n }\n\n subRelationsToBuild.forEach(({ type, localized, target }, key) => {\n if (type === 'one') {\n const blockWithLocalized = localized\n ? `${blockTableName}${adapter.localesSuffix}`\n : blockTableName\n\n blockRelations[key] = {\n type: 'one',\n fields: [\n {\n name: key,\n table: blockWithLocalized,\n },\n ],\n references: ['id'],\n relationName: key,\n to: target,\n }\n }\n\n if (type === 'many') {\n blockRelations[key] = {\n type: 'many',\n relationName: key,\n to: target,\n }\n }\n })\n\n adapter.rawRelations[blockTableName] = blockRelations\n }\n\n // blocks relationships are defined from the collection or globals table down to the block, bypassing any subBlocks\n rootRelationsToBuild.set(relationName, {\n type: 'many',\n // blocks are not localized on the parent table\n localized: false,\n target: blockTableName,\n })\n })\n\n break\n }\n case 'checkbox': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'boolean',\n },\n field,\n )\n\n break\n }\n\n case 'code':\n case 'email':\n case 'slug':\n case 'textarea': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n\n break\n }\n\n case 'date': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'timestamp',\n mode: 'string',\n precision: 3,\n withTimezone: true,\n },\n field,\n )\n\n break\n }\n\n case 'group':\n case 'tab': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const {\n hasLocalizedField: groupHasLocalizedField,\n hasLocalizedManyNumberField: groupHasLocalizedManyNumberField,\n hasLocalizedManyTextField: groupHasLocalizedManyTextField,\n hasLocalizedRelationshipField: groupHasLocalizedRelationshipField,\n hasManyNumberField: groupHasManyNumberField,\n hasManyTextField: groupHasManyTextField,\n } = traverseFields({\n adapter,\n blocksTableNameMap,\n columnPrefix: `${columnName}_`,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix: `${fieldName}.`,\n fields: field.flattenedFields,\n forceLocalized: isFieldLocalized || Boolean(forceLocalized),\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: `${parentTableName}_${columnName}`,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName,\n relationships,\n relationsToBuild,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n setColumnID,\n uniqueRelationships,\n versions,\n withinLocalizedArrayOrBlock: withinLocalizedArrayOrBlock || isFieldLocalized,\n })\n\n if (groupHasLocalizedField) {\n hasLocalizedField = true\n }\n if (groupHasLocalizedRelationshipField) {\n hasLocalizedRelationshipField = true\n }\n if (groupHasManyTextField) {\n hasManyTextField = true\n }\n if (groupHasLocalizedManyTextField) {\n hasLocalizedManyTextField = true\n }\n if (groupHasManyNumberField) {\n hasManyNumberField = true\n }\n if (groupHasLocalizedManyNumberField) {\n hasLocalizedManyNumberField = true\n }\n break\n }\n\n case 'json':\n case 'richText': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'jsonb',\n },\n field,\n )\n\n break\n }\n\n case 'number': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n hasLocalizedManyNumberField = true\n }\n\n if (field.index) {\n hasManyNumberField = 'index'\n } else if (!hasManyNumberField) {\n hasManyNumberField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany number fields.',\n )\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'numeric',\n },\n field,\n )\n }\n\n break\n }\n\n case 'point': {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'geometry',\n },\n field,\n )\n\n break\n }\n\n case 'radio':\n case 'select': {\n const enumName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n })\n\n const options = field.options.map((option) => {\n if (optionIsObject(option)) {\n return option.value\n }\n\n return option\n })\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `${newTableName}_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n\n const baseColumns: Record<string, RawColumn> = {\n order: {\n name: 'order',\n type: 'integer',\n notNull: true,\n },\n parent: {\n name: 'parent_id',\n type: parentIDColType,\n notNull: true,\n },\n value: {\n name: 'value',\n type: 'enum',\n enumName: createTableName({\n adapter,\n config: field,\n parentTableName: newTableName,\n prefix: `enum_${newTableName}_`,\n target: 'enumName',\n throwValidationError,\n }),\n options,\n },\n }\n\n const baseIndexes: Record<string, RawIndex> = {\n orderIdx: {\n name: fitIdentifierLength({\n name: `${selectTableName}_order`,\n adapter,\n suffix: '_idx',\n }),\n on: 'order',\n },\n parentIdx: {\n name: fitIdentifierLength({\n name: `${selectTableName}_parent`,\n adapter,\n suffix: '_idx',\n }),\n on: 'parent',\n },\n }\n\n const baseForeignKeys: Record<string, RawForeignKey> = {\n parentFk: {\n name: fitIdentifierLength({\n name: `${selectTableName}_parent`,\n adapter,\n suffix: '_fk',\n }),\n columns: ['parent'],\n foreignColumns: [\n {\n name: 'id',\n table: parentTableName,\n },\n ],\n onDelete: 'cascade',\n },\n }\n\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n baseColumns.locale = {\n name: 'locale',\n type: 'enum',\n locale: true,\n notNull: true,\n }\n\n baseIndexes.localeIdx = {\n name: fitIdentifierLength({\n name: `${selectTableName}_locale`,\n adapter,\n suffix: '_idx',\n }),\n on: 'locale',\n }\n }\n\n if (field.index) {\n baseIndexes.value = {\n name: fitIdentifierLength({\n name: `${selectTableName}_value`,\n adapter,\n suffix: '_idx',\n }),\n on: 'value',\n }\n }\n\n buildTable({\n adapter,\n baseColumns,\n baseForeignKeys,\n baseIndexes,\n blocksTableNameMap,\n disableNotNull,\n disableUnique,\n fields: [],\n parentIsLocalized: parentIsLocalized || field.localized,\n rootTableName,\n setColumnID,\n tableName: selectTableName,\n versions,\n })\n\n relationsToBuild.set(fieldName, {\n type: 'many',\n // selects have their own localized table, independent of the base table.\n localized: false,\n target: selectTableName,\n })\n\n adapter.rawRelations[selectTableName] = {\n parent: {\n type: 'one',\n fields: [\n {\n name: 'parent',\n table: selectTableName,\n },\n ],\n references: ['id'],\n relationName: fieldName,\n to: parentTableName,\n },\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'enum',\n enumName,\n options,\n },\n field,\n )\n }\n break\n }\n\n case 'relationship':\n case 'upload':\n if (Array.isArray(field.relationTo)) {\n field.relationTo.forEach((relation) => {\n relationships.add(relation)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(relation)\n }\n })\n } else if (field.hasMany) {\n relationships.add(field.relationTo)\n if (field.unique && !disableUnique && !disableRelsTableUnique) {\n uniqueRelationships.add(field.relationTo)\n }\n } else {\n // simple relationships get a column on the targetTable with a foreign key to the relationTo table\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n const tableName = adapter.tableNameMap.get(toSnakeCase(field.relationTo))\n\n // get the id type of the related collection\n let colType: IDType = isUUIDType(adapter.idType) ? 'uuid' : 'integer'\n const relatedCollectionCustomID = relationshipConfig.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n if (relatedCollectionCustomID?.type === 'number') {\n colType = 'numeric'\n }\n if (relatedCollectionCustomID?.type === 'text') {\n colType = 'varchar'\n }\n\n // make the foreign key column for relationship using the correct id column type\n targetTable[fieldName] = {\n name: `${columnName}_id`,\n type: colType,\n reference: {\n name: 'id',\n onDelete: 'set null',\n table: tableName,\n },\n }\n\n // add relationship to table\n relationsToBuild.set(fieldName, {\n type: 'one',\n localized: adapter.payload.config.localization && (isFieldLocalized || forceLocalized),\n target: tableName,\n })\n\n // add notNull when not required\n if (!disableNotNull && field.required && !field.admin?.condition) {\n targetTable[fieldName].notNull = true\n }\n break\n }\n\n if (\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock\n ) {\n hasLocalizedRelationshipField = true\n }\n\n break\n\n case 'text': {\n if (field.hasMany) {\n const isLocalized =\n Boolean(isFieldLocalized && adapter.payload.config.localization) ||\n withinLocalizedArrayOrBlock ||\n forceLocalized\n\n if (isLocalized) {\n hasLocalizedManyTextField = true\n }\n\n if (field.index) {\n hasManyTextField = 'index'\n } else if (!hasManyTextField) {\n hasManyTextField = true\n }\n\n if (field.unique) {\n throw new InvalidConfiguration(\n 'Unique is not supported in Postgres for hasMany text fields.',\n )\n }\n } else {\n targetTable[fieldName] = withDefault(\n {\n name: columnName,\n type: 'varchar',\n },\n field,\n )\n }\n break\n }\n\n default:\n break\n }\n\n const condition = field.admin && field.admin.condition\n\n if (\n !disableNotNull &&\n targetTable[fieldName] &&\n 'required' in field &&\n field.required &&\n !condition\n ) {\n targetTable[fieldName].notNull = true\n }\n })\n\n return {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n }\n}\n"],"names":["InvalidConfiguration","fieldAffectsData","fieldIsVirtual","fieldShouldBeLocalized","optionIsObject","toSnakeCase","createTableName","buildIndexName","fitIdentifierLength","getArrayRelationName","hasLocalesTable","isUUIDType","InternalBlockTableNameIndex","setInternalBlockIndex","validateExistingBlockIsIdentical","buildTable","idToUUID","withDefault","traverseFields","adapter","blocksTableNameMap","columnPrefix","columns","disableNotNull","disableRelsTableUnique","disableUnique","fieldPrefix","fields","forceLocalized","indexes","localesColumns","localesIndexes","newTableName","parentIsLocalized","parentTableName","relationships","relationsToBuild","rootRelationsToBuild","rootTableIDColType","rootTableName","setColumnID","uniqueRelationships","versions","withinLocalizedArrayOrBlock","throwValidationError","hasLocalizedField","hasLocalizedRelationshipField","hasManyTextField","hasLocalizedManyTextField","hasManyNumberField","hasLocalizedManyNumberField","parentIDColType","idColumn","id","includes","type","forEach","field","name","targetTable","targetIndexes","columnName","fieldName","replace","isFieldLocalized","payload","config","localization","blocksAsJSON","hasMany","unique","index","Array","isArray","relationTo","constraintValue","fieldConstraints","indexName","on","disableNotNullFromHere","Boolean","admin","condition","arrayTableName","prefix","versionsCustomName","baseColumns","_order","notNull","_parentID","baseIndexes","_orderIdx","suffix","_parentIDIdx","baseForeignKeys","_parentIDFk","foreignColumns","table","onDelete","isLocalized","_locale","locale","_localeIdx","subHasLocalizedManyNumberField","subHasLocalizedManyTextField","subHasLocalizedRelationshipField","subHasManyNumberField","subHasManyTextField","subRelationsToBuild","flattenedFields","localized","rootRelationships","rootUniqueRelationships","tableName","relationName","path","set","target","arrayRelations","references","to","_locales","localesSuffix","key","arrayWithLocalized","rawRelations","blocks","_block","block","blockTableName","isLocalizedBlockTable","rawTables","tableLocales","slug","_path","_pathIdx","_parentIdFk","blockRelations","blockWithLocalized","mode","precision","withTimezone","groupHasLocalizedField","groupHasLocalizedManyNumberField","groupHasLocalizedManyTextField","groupHasLocalizedRelationshipField","groupHasManyNumberField","groupHasManyTextField","enumName","options","map","option","value","selectTableName","order","parent","orderIdx","parentIdx","parentFk","localeIdx","relation","add","relationshipConfig","collections","tableNameMap","get","colType","idType","relatedCollectionCustomID","find","reference","required"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAS;AAC9C,SACEC,gBAAgB,EAChBC,cAAc,EACdC,sBAAsB,EACtBC,cAAc,QACT,iBAAgB;AACvB,OAAOC,iBAAiB,gBAAe;AAavC,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,UAAU,QAAQ,6BAA4B;AACvD,SACEC,2BAA2B,EAC3BC,qBAAqB,EACrBC,gCAAgC,QAC3B,mDAAkD;AACzD,SAASC,UAAU,QAAQ,aAAY;AACvC,SAASC,QAAQ,QAAQ,gBAAe;AACxC,SAASC,WAAW,QAAQ,mBAAkB;AA2C9C,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,kBAAkB,EAClBC,YAAY,EACZC,OAAO,EACPC,cAAc,EACdC,sBAAsB,EACtBC,gBAAgB,KAAK,EACrBC,WAAW,EACXC,MAAM,EACNC,cAAc,EACdC,OAAO,EACPC,cAAc,EACdC,cAAc,EACdC,YAAY,EACZC,iBAAiB,EACjBC,eAAe,EACfC,aAAa,EACbC,gBAAgB,EAChBC,oBAAoB,EACpBC,kBAAkB,EAClBC,aAAa,EACbC,WAAW,EACXC,mBAAmB,EACnBC,QAAQ,EACRC,2BAA2B,EACtB;IACL,MAAMC,uBAAuB;IAC7B,IAAIC,oBAAoB;IACxB,IAAIC,gCAAgC;IACpC,IAAIC,mBAAsC;IAC1C,IAAIC,4BAA4B;IAChC,IAAIC,qBAAwC;IAC5C,IAAIC,8BAA8B;IAElC,IAAIC,kBAA0B;IAE9B,MAAMC,WAAW9B,QAAQ+B,EAAE;IAE3B,IAAID,YAAY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QAAQJ;oBACV;oBAEA,gCAAgC;oBAChC,IAAI,CAAC1F,kBAAkBkC,MAAMkH,QAAQ,IAAI,CAAClH,MAAMwB,KAAK,EAAEC,WAAW;wBAChEvB,WAAW,CAACG,UAAU,CAAC0B,OAAO,GAAG;oBACnC;oBACA;gBACF;gBAEA,IACER,QAAQhB,oBAAoB7C,QAAQ8C,OAAO,CAACC,MAAM,CAACC,YAAY,KAC/DxB,6BACA;oBACAG,gCAAgC;gBAClC;gBAEA;YAEF,KAAK;gBAAQ;oBACX,IAAIW,MAAMY,OAAO,EAAE;wBACjB,MAAM8B,cACJnB,QAAQhB,oBAAoB7C,QAAQ8C,OAAO,CAACC,MAAM,CAACC,YAAY,KAC/DxB,+BACAf;wBAEF,IAAIuE,aAAa;4BACfnD,4BAA4B;wBAC9B;wBAEA,IAAIS,MAAMc,KAAK,EAAE;4BACfxB,mBAAmB;wBACrB,OAAO,IAAI,CAACA,kBAAkB;4BAC5BA,mBAAmB;wBACrB;wBAEA,IAAIU,MAAMa,MAAM,EAAE;4BAChB,MAAM,IAAItE,qBACR;wBAEJ;oBACF,OAAO;wBACL2D,WAAW,CAACG,UAAU,GAAG7C,YACvB;4BACEyC,MAAMG;4BACNN,MAAM;wBACR,GACAE;oBAEJ;oBACA;gBACF;YAEA;gBACE;QACJ;QAEA,MAAMyB,YAAYzB,MAAMwB,KAAK,IAAIxB,MAAMwB,KAAK,CAACC,SAAS;QAEtD,IACE,CAAC3D,kBACDoC,WAAW,CAACG,UAAU,IACtB,cAAcL,SACdA,MAAMkH,QAAQ,IACd,CAACzF,WACD;YACAvB,WAAW,CAACG,UAAU,CAAC0B,OAAO,GAAG;QACnC;IACF;IAEA,OAAO;QACL3C;QACAK;QACAF;QACAF;QACAG;QACAF;IACF;AACF,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FlattenedArrayField } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from '../../types.js';
|
|
3
|
-
import type { ArrayRowToInsert, BlockRowToInsert, NumberToDelete, RelationshipToDelete, TextToDelete } from './types.js';
|
|
3
|
+
import type { ArrayRowToInsert, BlockRowToInsert, NumberToDelete, RelationshipToDelete, RowToInsert, TextToDelete } from './types.js';
|
|
4
4
|
type Args = {
|
|
5
5
|
adapter: DrizzleAdapter;
|
|
6
6
|
arrayTableName: string;
|
|
@@ -16,6 +16,7 @@ type Args = {
|
|
|
16
16
|
numbersToDelete: NumberToDelete[];
|
|
17
17
|
parentIsLocalized: boolean;
|
|
18
18
|
path: string;
|
|
19
|
+
pathPrefixesToDelete: RowToInsert['pathPrefixesToDelete'];
|
|
19
20
|
relationships: Record<string, unknown>[];
|
|
20
21
|
relationshipsToDelete: RelationshipToDelete[];
|
|
21
22
|
selects: {
|
|
@@ -29,6 +30,6 @@ type Args = {
|
|
|
29
30
|
*/
|
|
30
31
|
withinArrayOrBlockLocale?: string;
|
|
31
32
|
};
|
|
32
|
-
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale, }: Args) => ArrayRowToInsert[];
|
|
33
|
+
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, pathPrefixesToDelete, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale, }: Args) => ArrayRowToInsert[];
|
|
33
34
|
export {};
|
|
34
35
|
//# 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;AAIlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EACV,gBAAgB,EAChB,gBA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B,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAA;AAKnB,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,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,iBAAiB,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB,EAAE,WAAW,CAAC,sBAAsB,CAAC,CAAA;IACzD,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,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,cAAc,qQAoBxB,IAAI,uBA0EN,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fieldShouldBeLocalized } from 'payload/shared';
|
|
2
2
|
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
|
3
3
|
import { traverseFields } from './traverseFields.js';
|
|
4
|
-
export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale })=>{
|
|
4
|
+
export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, pathPrefixesToDelete, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale })=>{
|
|
5
5
|
const newRows = [];
|
|
6
6
|
const hasUUID = adapter.tables[arrayTableName]._uuid;
|
|
7
7
|
if (isArrayOfRows(data)) {
|
|
@@ -55,6 +55,7 @@ export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks,
|
|
|
55
55
|
parentIsLocalized: parentIsLocalized || field.localized,
|
|
56
56
|
parentTableName: arrayTableName,
|
|
57
57
|
path: `${path || ''}${field.name}.${i}.`,
|
|
58
|
+
pathPrefixesToDelete,
|
|
58
59
|
relationships,
|
|
59
60
|
relationshipsToAppend: [],
|
|
60
61
|
relationshipsToDelete,
|
|
@@ -1 +1 @@
|
|
|
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 {\n ArrayRowToInsert,\n BlockRowToInsert,\n NumberToDelete,\n RelationshipToDelete,\n TextToDelete,\n} 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 numbersToDelete: NumberToDelete[]\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 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 transformArray = ({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n numbersToDelete,\n parentIsLocalized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\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 arraysToPush: {},\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 arraysToPush: newRow.arraysToPush,\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName: arrayTableName,\n path: `${path || ''}${field.name}.${i}.`,\n relationships,\n relationshipsToAppend: [],\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n textsToDelete,\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","numbersToDelete","parentIsLocalized","path","relationships","relationshipsToDelete","selects","texts","textsToDelete","withinArrayOrBlockLocale","newRows","hasUUID","tables","_uuid","forEach","arrayRow","i","newRow","arrays","arraysToPush","locales","row","_order","id","_locale","columnPrefix","fieldPrefix","fields","flattenedFields","insideArrayOrBlock","localized","parentTableName","name","relationshipsToAppend","push"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,iBAAgB;
|
|
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 {\n ArrayRowToInsert,\n BlockRowToInsert,\n NumberToDelete,\n RelationshipToDelete,\n RowToInsert,\n TextToDelete,\n} 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 numbersToDelete: NumberToDelete[]\n parentIsLocalized: boolean\n path: string\n pathPrefixesToDelete: RowToInsert['pathPrefixesToDelete']\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\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 transformArray = ({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n numbersToDelete,\n parentIsLocalized,\n path,\n pathPrefixesToDelete,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\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 arraysToPush: {},\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 arraysToPush: newRow.arraysToPush,\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName: arrayTableName,\n path: `${path || ''}${field.name}.${i}.`,\n pathPrefixesToDelete,\n relationships,\n relationshipsToAppend: [],\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n textsToDelete,\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","numbersToDelete","parentIsLocalized","path","pathPrefixesToDelete","relationships","relationshipsToDelete","selects","texts","textsToDelete","withinArrayOrBlockLocale","newRows","hasUUID","tables","_uuid","forEach","arrayRow","i","newRow","arrays","arraysToPush","locales","row","_order","id","_locale","columnPrefix","fieldPrefix","fields","flattenedFields","insideArrayOrBlock","localized","parentTableName","name","relationshipsToAppend","push"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,iBAAgB;AAYvD,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AAgCpD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,eAAe,EACfC,iBAAiB,EACjBC,IAAI,EACJC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,OAAO,EACPC,KAAK,EACLC,aAAa,EACbC,wBAAwB,EACnB;IACL,MAAMC,UAA8B,EAAE;IAEtC,MAAMC,UAAUpB,QAAQqB,MAAM,CAACpB,eAAe,CAACqB,KAAK;IAEpD,IAAIzB,cAAcQ,OAAO;QACvBA,KAAKkB,OAAO,CAAC,CAACC,UAAUC;YACtB,MAAMC,SAA2B;gBAC/BC,QAAQ,CAAC;gBACTC,cAAc,CAAC;gBACfC,SAAS,CAAC;gBACVC,KAAK;oBACHC,QAAQN,IAAI;gBACd;YACF;YAEA,+CAA+C;YAC/C,sCAAsC;YACtC,4CAA4C;YAC5C,6CAA6C;YAC7C,+DAA+D;YAC/D,IAAIL,SAAS;gBACXM,OAAOI,GAAG,CAACR,KAAK,GAAGE,SAASQ,EAAE;gBAC9B,OAAOR,SAASQ,EAAE;YACpB;YAEA,IAAIzB,QAAQ;gBACVmB,OAAOG,OAAO,CAACtB,OAAO,GAAG;oBACvB0B,SAAS1B;gBACX;YACF;YAEA,IAAIX,uBAAuB;gBAAEU;gBAAOI;YAAkB,MAAMH,QAAQ;gBAClEmB,OAAOI,GAAG,CAACG,OAAO,GAAG1B;YACvB;YAEA,IAAIW,0BAA0B;gBAC5BQ,OAAOI,GAAG,CAACG,OAAO,GAAGf;YACvB;YAEApB,eAAe;gBACbE;gBACA2B,QAAQD,OAAOC,MAAM;gBACrBC,cAAcF,OAAOE,YAAY;gBACjC1B;gBACAC;gBACAC;gBACA8B,cAAc;gBACd7B,MAAMmB;gBACNW,aAAa;gBACbC,QAAQ9B,MAAM+B,eAAe;gBAC7BC,oBAAoB;gBACpBT,SAASH,OAAOG,OAAO;gBACvBrB;gBACAC;gBACAC,mBAAmBA,qBAAqBJ,MAAMiC,SAAS;gBACvDC,iBAAiBvC;gBACjBU,MAAM,GAAGA,QAAQ,KAAKL,MAAMmC,IAAI,CAAC,CAAC,EAAEhB,EAAE,CAAC,CAAC;gBACxCb;gBACAC;gBACA6B,uBAAuB,EAAE;gBACzB5B;gBACAgB,KAAKJ,OAAOI,GAAG;gBACff;gBACAC;gBACAC;gBACAC;YACF;YAEAC,QAAQwB,IAAI,CAACjB;QACf;IACF;IAEA,OAAOP;AACT,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FlattenedBlocksField } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from '../../types.js';
|
|
3
|
-
import type { BlockRowToInsert, NumberToDelete, RelationshipToDelete, TextToDelete } from './types.js';
|
|
3
|
+
import type { BlockRowToInsert, NumberToDelete, RelationshipToDelete, RowToInsert, TextToDelete } from './types.js';
|
|
4
4
|
type Args = {
|
|
5
5
|
adapter: DrizzleAdapter;
|
|
6
6
|
baseTableName: string;
|
|
@@ -15,6 +15,7 @@ type Args = {
|
|
|
15
15
|
numbersToDelete: NumberToDelete[];
|
|
16
16
|
parentIsLocalized: boolean;
|
|
17
17
|
path: string;
|
|
18
|
+
pathPrefixesToDelete: RowToInsert['pathPrefixesToDelete'];
|
|
18
19
|
relationships: Record<string, unknown>[];
|
|
19
20
|
relationshipsToDelete: RelationshipToDelete[];
|
|
20
21
|
selects: {
|
|
@@ -28,6 +29,6 @@ type Args = {
|
|
|
28
29
|
*/
|
|
29
30
|
withinArrayOrBlockLocale?: string;
|
|
30
31
|
};
|
|
31
|
-
export declare const transformBlocks: ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale, }: Args) => void;
|
|
32
|
+
export declare const transformBlocks: ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, pathPrefixesToDelete, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale, }: Args) => void;
|
|
32
33
|
export {};
|
|
33
34
|
//# 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,EAAkB,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACb,MAAM,YAAY,CAAA;AAKnB,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,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,iBAAiB,EAAE,OAAO,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O,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,oBAAoB,EAAE,WAAW,CAAC,sBAAsB,CAAC,CAAA;IACzD,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,aAAa,EAAE,YAAY,EAAE,CAAA;IAC7B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AACD,eAAO,MAAM,eAAe,qPAmBzB,IAAI,SAuFN,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { fieldShouldBeLocalized } from 'payload/shared';
|
|
|
2
2
|
import toSnakeCase from 'to-snake-case';
|
|
3
3
|
import { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.js';
|
|
4
4
|
import { traverseFields } from './traverseFields.js';
|
|
5
|
-
export const transformBlocks = ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale })=>{
|
|
5
|
+
export const transformBlocks = ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, numbersToDelete, parentIsLocalized, path, pathPrefixesToDelete, relationships, relationshipsToDelete, selects, texts, textsToDelete, withinArrayOrBlockLocale })=>{
|
|
6
6
|
data.forEach((blockRow, i)=>{
|
|
7
7
|
if (typeof blockRow.blockType !== 'string') {
|
|
8
8
|
return;
|
|
@@ -64,6 +64,7 @@ export const transformBlocks = ({ adapter, baseTableName, blocks, blocksToDelete
|
|
|
64
64
|
parentIsLocalized: parentIsLocalized || field.localized,
|
|
65
65
|
parentTableName: blockTableName,
|
|
66
66
|
path: `${path || ''}${field.name}.${i}.`,
|
|
67
|
+
pathPrefixesToDelete,
|
|
67
68
|
relationships,
|
|
68
69
|
relationshipsToAppend: [],
|
|
69
70
|
relationshipsToDelete,
|
|
@@ -1 +1 @@
|
|
|
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 {\n BlockRowToInsert,\n NumberToDelete,\n RelationshipToDelete,\n TextToDelete,\n} from './types.js'\n\nimport { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.js'\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 numbersToDelete: NumberToDelete[]\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 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}\nexport const transformBlocks = ({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n numbersToDelete,\n parentIsLocalized,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n}: Args) => {\n data.forEach((blockRow, i) => {\n if (typeof blockRow.blockType !== 'string') {\n return\n }\n\n const fieldBlock = field.blocks.find((block) =>\n typeof block === 'string' ? block === blockRow.blockType : block.slug === blockRow.blockType,\n )\n const registeredBlocks: Record<string, FlattenedBlock | undefined> = adapter.payload.blocks\n const matchedBlock: FlattenedBlock | undefined =\n typeof fieldBlock === 'string' ? registeredBlocks[fieldBlock] : fieldBlock\n\n if (!matchedBlock) {\n return\n }\n const blockType = toSnakeCase(blockRow.blockType)\n\n const newRow: BlockRowToInsert = {\n arrays: {},\n arraysToPush: {},\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 = resolveBlockTableName(\n matchedBlock,\n adapter.tableNameMap.get(`${baseTableName}_blocks_${blockType}`),\n )\n\n if (!blocks[blockTableName]) {\n blocks[blockTableName] = []\n }\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 arraysToPush: newRow.arraysToPush,\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName: blockTableName,\n path: `${path || ''}${field.name}.${i}.`,\n relationships,\n relationshipsToAppend: [],\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n\n blocks[blockTableName].push(newRow)\n })\n}\n"],"names":["fieldShouldBeLocalized","toSnakeCase","resolveBlockTableName","traverseFields","transformBlocks","adapter","baseTableName","blocks","blocksToDelete","data","field","locale","numbers","numbersToDelete","parentIsLocalized","path","relationships","relationshipsToDelete","selects","texts","textsToDelete","withinArrayOrBlockLocale","forEach","blockRow","i","blockType","fieldBlock","find","block","slug","registeredBlocks","payload","matchedBlock","newRow","arrays","arraysToPush","locales","row","_order","_path","name","_locale","blockTableName","tableNameMap","get","hasUUID","tables","_uuid","id","columnPrefix","fieldPrefix","fields","flattenedFields","insideArrayOrBlock","localized","parentTableName","relationshipsToAppend","push"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,OAAOC,iBAAiB,gBAAe;
|
|
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 {\n BlockRowToInsert,\n NumberToDelete,\n RelationshipToDelete,\n RowToInsert,\n TextToDelete,\n} from './types.js'\n\nimport { resolveBlockTableName } from '../../utilities/validateExistingBlockIsIdentical.js'\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 numbersToDelete: NumberToDelete[]\n parentIsLocalized: boolean\n path: string\n pathPrefixesToDelete: RowToInsert['pathPrefixesToDelete']\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\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}\nexport const transformBlocks = ({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n numbersToDelete,\n parentIsLocalized,\n path,\n pathPrefixesToDelete,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n}: Args) => {\n data.forEach((blockRow, i) => {\n if (typeof blockRow.blockType !== 'string') {\n return\n }\n\n const fieldBlock = field.blocks.find((block) =>\n typeof block === 'string' ? block === blockRow.blockType : block.slug === blockRow.blockType,\n )\n const registeredBlocks: Record<string, FlattenedBlock | undefined> = adapter.payload.blocks\n const matchedBlock: FlattenedBlock | undefined =\n typeof fieldBlock === 'string' ? registeredBlocks[fieldBlock] : fieldBlock\n\n if (!matchedBlock) {\n return\n }\n const blockType = toSnakeCase(blockRow.blockType)\n\n const newRow: BlockRowToInsert = {\n arrays: {},\n arraysToPush: {},\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 = resolveBlockTableName(\n matchedBlock,\n adapter.tableNameMap.get(`${baseTableName}_blocks_${blockType}`),\n )\n\n if (!blocks[blockTableName]) {\n blocks[blockTableName] = []\n }\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 arraysToPush: newRow.arraysToPush,\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 numbersToDelete,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentTableName: blockTableName,\n path: `${path || ''}${field.name}.${i}.`,\n pathPrefixesToDelete,\n relationships,\n relationshipsToAppend: [],\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n textsToDelete,\n withinArrayOrBlockLocale,\n })\n\n blocks[blockTableName].push(newRow)\n })\n}\n"],"names":["fieldShouldBeLocalized","toSnakeCase","resolveBlockTableName","traverseFields","transformBlocks","adapter","baseTableName","blocks","blocksToDelete","data","field","locale","numbers","numbersToDelete","parentIsLocalized","path","pathPrefixesToDelete","relationships","relationshipsToDelete","selects","texts","textsToDelete","withinArrayOrBlockLocale","forEach","blockRow","i","blockType","fieldBlock","find","block","slug","registeredBlocks","payload","matchedBlock","newRow","arrays","arraysToPush","locales","row","_order","_path","name","_locale","blockTableName","tableNameMap","get","hasUUID","tables","_uuid","id","columnPrefix","fieldPrefix","fields","flattenedFields","insideArrayOrBlock","localized","parentTableName","relationshipsToAppend","push"],"mappings":"AAEA,SAASA,sBAAsB,QAAQ,iBAAgB;AACvD,OAAOC,iBAAiB,gBAAe;AAWvC,SAASC,qBAAqB,QAAQ,sDAAqD;AAC3F,SAASC,cAAc,QAAQ,sBAAqB;AA8BpD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,OAAO,EACPC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,eAAe,EACfC,iBAAiB,EACjBC,IAAI,EACJC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,OAAO,EACPC,KAAK,EACLC,aAAa,EACbC,wBAAwB,EACnB;IACLb,KAAKc,OAAO,CAAC,CAACC,UAAUC;QACtB,IAAI,OAAOD,SAASE,SAAS,KAAK,UAAU;YAC1C;QACF;QAEA,MAAMC,aAAajB,MAAMH,MAAM,CAACqB,IAAI,CAAC,CAACC,QACpC,OAAOA,UAAU,WAAWA,UAAUL,SAASE,SAAS,GAAGG,MAAMC,IAAI,KAAKN,SAASE,SAAS;QAE9F,MAAMK,mBAA+D1B,QAAQ2B,OAAO,CAACzB,MAAM;QAC3F,MAAM0B,eACJ,OAAON,eAAe,WAAWI,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B,IAAI,CAAC,CAAC,EAAEhB,EAAE,CAAC,CAAC;YACxCT;YACAC;YACAwC,uBAAuB,EAAE;YACzBvC;YACAoB,KAAKJ,OAAOI,GAAG;YACfnB;YACAC;YACAC;YACAC;QACF;QAEAf,MAAM,CAACoC,eAAe,CAACe,IAAI,CAACxB;IAC9B;AACF,EAAC"}
|
|
@@ -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;AAI7C,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,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,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,uFAQ3B,IAAI,KAAG,
|
|
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;AAI7C,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,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,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,uFAQ3B,IAAI,KAAG,WAoDT,CAAA"}
|
|
@@ -10,6 +10,7 @@ export const transformForWrite = ({ adapter, data, enableAtomicWrites, fields, p
|
|
|
10
10
|
locales: {},
|
|
11
11
|
numbers: [],
|
|
12
12
|
numbersToDelete: [],
|
|
13
|
+
pathPrefixesToDelete: new Set(),
|
|
13
14
|
relationships: [],
|
|
14
15
|
relationshipsToAppend: [],
|
|
15
16
|
relationshipsToDelete: [],
|
|
@@ -39,6 +40,7 @@ export const transformForWrite = ({ adapter, data, enableAtomicWrites, fields, p
|
|
|
39
40
|
parentIsLocalized,
|
|
40
41
|
parentTableName: tableName,
|
|
41
42
|
path,
|
|
43
|
+
pathPrefixesToDelete: rowToInsert.pathPrefixesToDelete,
|
|
42
44
|
relationships: rowToInsert.relationships,
|
|
43
45
|
relationshipsToAppend: rowToInsert.relationshipsToAppend,
|
|
44
46
|
relationshipsToDelete: rowToInsert.relationshipsToDelete,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/index.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { deepCopyObjectSimple } 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 enableAtomicWrites?: boolean\n fields: FlattenedField[]\n parentIsLocalized?: boolean\n path?: string\n tableName: string\n}\n\nexport const transformForWrite = ({\n adapter,\n data,\n enableAtomicWrites,\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 arraysToPush: {},\n blocks: {},\n blocksToDelete: new Set(),\n locales: {},\n numbers: [],\n numbersToDelete: [],\n relationships: [],\n relationshipsToAppend: [],\n relationshipsToDelete: [],\n row: {},\n selects: {},\n texts: [],\n textsToDelete: [],\n }\n\n // This function is responsible for building up the\n // above rowToInsert\n traverseFields({\n adapter,\n arrays: rowToInsert.arrays,\n arraysToPush: rowToInsert.arraysToPush,\n baseTableName: tableName,\n blocks: rowToInsert.blocks,\n blocksToDelete: rowToInsert.blocksToDelete,\n columnPrefix: '',\n // Traversal rewrites row IDs and annotates nested groups for relational storage.\n data: deepCopyObjectSimple(data),\n enableAtomicWrites,\n fieldPrefix: '',\n fields,\n locales: rowToInsert.locales,\n numbers: rowToInsert.numbers,\n numbersToDelete: rowToInsert.numbersToDelete,\n parentIsLocalized,\n parentTableName: tableName,\n path,\n relationships: rowToInsert.relationships,\n relationshipsToAppend: rowToInsert.relationshipsToAppend,\n relationshipsToDelete: rowToInsert.relationshipsToDelete,\n row: rowToInsert.row,\n selects: rowToInsert.selects,\n texts: rowToInsert.texts,\n textsToDelete: rowToInsert.textsToDelete,\n })\n\n return rowToInsert\n}\n"],"names":["deepCopyObjectSimple","traverseFields","transformForWrite","adapter","data","enableAtomicWrites","fields","parentIsLocalized","path","tableName","rowToInsert","arrays","arraysToPush","blocks","blocksToDelete","Set","locales","numbers","numbersToDelete","relationships","relationshipsToAppend","relationshipsToDelete","row","selects","texts","textsToDelete","baseTableName","columnPrefix","fieldPrefix","parentTableName"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAS;AAK9C,SAASC,cAAc,QAAQ,sBAAqB;AAYpD,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,OAAO,EACPC,IAAI,EACJC,kBAAkB,EAClBC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EAAE,EACTC,SAAS,EACJ;IACL,2DAA2D;IAC3D,MAAMC,cAA2B;QAC/BC,QAAQ,CAAC;QACTC,cAAc,CAAC;QACfC,QAAQ,CAAC;QACTC,gBAAgB,IAAIC;QACpBC,SAAS,CAAC;QACVC,SAAS,EAAE;QACXC,iBAAiB,EAAE;QACnBC,eAAe,EAAE;QACjBC,uBAAuB,EAAE;QACzBC,uBAAuB,EAAE;QACzBC,KAAK,CAAC;QACNC,SAAS,CAAC;QACVC,OAAO,EAAE;QACTC,eAAe,EAAE;IACnB;IAEA,mDAAmD;IACnD,oBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/index.ts"],"sourcesContent":["import type { FlattenedField } from 'payload'\n\nimport { deepCopyObjectSimple } 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 enableAtomicWrites?: boolean\n fields: FlattenedField[]\n parentIsLocalized?: boolean\n path?: string\n tableName: string\n}\n\nexport const transformForWrite = ({\n adapter,\n data,\n enableAtomicWrites,\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 arraysToPush: {},\n blocks: {},\n blocksToDelete: new Set(),\n locales: {},\n numbers: [],\n numbersToDelete: [],\n pathPrefixesToDelete: new Set(),\n relationships: [],\n relationshipsToAppend: [],\n relationshipsToDelete: [],\n row: {},\n selects: {},\n texts: [],\n textsToDelete: [],\n }\n\n // This function is responsible for building up the\n // above rowToInsert\n traverseFields({\n adapter,\n arrays: rowToInsert.arrays,\n arraysToPush: rowToInsert.arraysToPush,\n baseTableName: tableName,\n blocks: rowToInsert.blocks,\n blocksToDelete: rowToInsert.blocksToDelete,\n columnPrefix: '',\n // Traversal rewrites row IDs and annotates nested groups for relational storage.\n data: deepCopyObjectSimple(data),\n enableAtomicWrites,\n fieldPrefix: '',\n fields,\n locales: rowToInsert.locales,\n numbers: rowToInsert.numbers,\n numbersToDelete: rowToInsert.numbersToDelete,\n parentIsLocalized,\n parentTableName: tableName,\n path,\n pathPrefixesToDelete: rowToInsert.pathPrefixesToDelete,\n relationships: rowToInsert.relationships,\n relationshipsToAppend: rowToInsert.relationshipsToAppend,\n relationshipsToDelete: rowToInsert.relationshipsToDelete,\n row: rowToInsert.row,\n selects: rowToInsert.selects,\n texts: rowToInsert.texts,\n textsToDelete: rowToInsert.textsToDelete,\n })\n\n return rowToInsert\n}\n"],"names":["deepCopyObjectSimple","traverseFields","transformForWrite","adapter","data","enableAtomicWrites","fields","parentIsLocalized","path","tableName","rowToInsert","arrays","arraysToPush","blocks","blocksToDelete","Set","locales","numbers","numbersToDelete","pathPrefixesToDelete","relationships","relationshipsToAppend","relationshipsToDelete","row","selects","texts","textsToDelete","baseTableName","columnPrefix","fieldPrefix","parentTableName"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAS;AAK9C,SAASC,cAAc,QAAQ,sBAAqB;AAYpD,OAAO,MAAMC,oBAAoB,CAAC,EAChCC,OAAO,EACPC,IAAI,EACJC,kBAAkB,EAClBC,MAAM,EACNC,iBAAiB,EACjBC,OAAO,EAAE,EACTC,SAAS,EACJ;IACL,2DAA2D;IAC3D,MAAMC,cAA2B;QAC/BC,QAAQ,CAAC;QACTC,cAAc,CAAC;QACfC,QAAQ,CAAC;QACTC,gBAAgB,IAAIC;QACpBC,SAAS,CAAC;QACVC,SAAS,EAAE;QACXC,iBAAiB,EAAE;QACnBC,sBAAsB,IAAIJ;QAC1BK,eAAe,EAAE;QACjBC,uBAAuB,EAAE;QACzBC,uBAAuB,EAAE;QACzBC,KAAK,CAAC;QACNC,SAAS,CAAC;QACVC,OAAO,EAAE;QACTC,eAAe,EAAE;IACnB;IAEA,mDAAmD;IACnD,oBAAoB;IACpBzB,eAAe;QACbE;QACAQ,QAAQD,YAAYC,MAAM;QAC1BC,cAAcF,YAAYE,YAAY;QACtCe,eAAelB;QACfI,QAAQH,YAAYG,MAAM;QAC1BC,gBAAgBJ,YAAYI,cAAc;QAC1Cc,cAAc;QACd,iFAAiF;QACjFxB,MAAMJ,qBAAqBI;QAC3BC;QACAwB,aAAa;QACbvB;QACAU,SAASN,YAAYM,OAAO;QAC5BC,SAASP,YAAYO,OAAO;QAC5BC,iBAAiBR,YAAYQ,eAAe;QAC5CX;QACAuB,iBAAiBrB;QACjBD;QACAW,sBAAsBT,YAAYS,oBAAoB;QACtDC,eAAeV,YAAYU,aAAa;QACxCC,uBAAuBX,YAAYW,qBAAqB;QACxDC,uBAAuBZ,YAAYY,qBAAqB;QACxDC,KAAKb,YAAYa,GAAG;QACpBC,SAASd,YAAYc,OAAO;QAC5BC,OAAOf,YAAYe,KAAK;QACxBC,eAAehB,YAAYgB,aAAa;IAC1C;IAEA,OAAOhB;AACT,EAAC"}
|
|
@@ -48,6 +48,7 @@ type Args = {
|
|
|
48
48
|
*/
|
|
49
49
|
parentTableName: string;
|
|
50
50
|
path: string;
|
|
51
|
+
pathPrefixesToDelete: RowToInsert['pathPrefixesToDelete'];
|
|
51
52
|
relationships: Record<string, unknown>[];
|
|
52
53
|
relationshipsToAppend: RelationshipToAppend[];
|
|
53
54
|
relationshipsToDelete: RelationshipToDelete[];
|
|
@@ -63,6 +64,6 @@ type Args = {
|
|
|
63
64
|
*/
|
|
64
65
|
withinArrayOrBlockLocale?: string;
|
|
65
66
|
};
|
|
66
|
-
export declare const 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, }: Args) => void;
|
|
67
|
+
export declare const traverseFields: ({ adapter, arrays, arraysToPush, baseTableName, blocks, blocksToDelete, columnPrefix, data, enableAtomicWrites, existingLocales, fieldPrefix, fields, forcedLocale, insideArrayOrBlock, locales, numbers, numbersToDelete, parentIsLocalized, parentTableName, path, pathPrefixesToDelete, relationships, relationshipsToAppend, relationshipsToDelete, row, selects, texts, textsToDelete, withinArrayOrBlockLocale, }: Args) => void;
|
|
67
68
|
export {};
|
|
68
69
|
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/write/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAIvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAA;AAWnB,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IAC7B;;;OAGG;IACH,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,CAAA;IACzC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;IAC7B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC3C;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,OAAO,EAAE;QACP,CAAC,MAA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