@payloadcms/db-postgres 3.0.0-canary.d6053cd → 3.0.0-canary.d894ac7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +10 -6
- package/dist/connect.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -67
- package/dist/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +3 -2
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.js +2 -2
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +3 -2
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +3 -2
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
- package/dist/types.d.ts +42 -78
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -9
- package/dist/count.d.ts +0 -3
- package/dist/count.d.ts.map +0 -1
- package/dist/count.js +0 -41
- package/dist/count.js.map +0 -1
- package/dist/create.d.ts +0 -3
- package/dist/create.d.ts.map +0 -1
- package/dist/create.js +0 -19
- package/dist/create.js.map +0 -1
- package/dist/createGlobal.d.ts +0 -4
- package/dist/createGlobal.d.ts.map +0 -1
- package/dist/createGlobal.js +0 -19
- package/dist/createGlobal.js.map +0 -1
- package/dist/createGlobalVersion.d.ts +0 -4
- package/dist/createGlobalVersion.d.ts.map +0 -1
- package/dist/createGlobalVersion.js +0 -33
- package/dist/createGlobalVersion.js.map +0 -1
- package/dist/createMigration.d.ts +0 -3
- package/dist/createMigration.d.ts.map +0 -1
- package/dist/createMigration.js +0 -102
- package/dist/createMigration.js.map +0 -1
- package/dist/createVersion.d.ts +0 -4
- package/dist/createVersion.d.ts.map +0 -1
- package/dist/createVersion.js +0 -40
- package/dist/createVersion.js.map +0 -1
- package/dist/deleteMany.d.ts +0 -3
- package/dist/deleteMany.d.ts.map +0 -1
- package/dist/deleteMany.js +0 -28
- package/dist/deleteMany.js.map +0 -1
- package/dist/deleteOne.d.ts +0 -3
- package/dist/deleteOne.d.ts.map +0 -1
- package/dist/deleteOne.js +0 -59
- package/dist/deleteOne.js.map +0 -1
- package/dist/deleteVersions.d.ts +0 -3
- package/dist/deleteVersions.d.ts.map +0 -1
- package/dist/deleteVersions.js +0 -31
- package/dist/deleteVersions.js.map +0 -1
- package/dist/destroy.d.ts +0 -3
- package/dist/destroy.d.ts.map +0 -1
- package/dist/destroy.js +0 -15
- package/dist/destroy.js.map +0 -1
- package/dist/find/buildFindManyArgs.d.ts +0 -17
- package/dist/find/buildFindManyArgs.d.ts.map +0 -1
- package/dist/find/buildFindManyArgs.js +0 -65
- package/dist/find/buildFindManyArgs.js.map +0 -1
- package/dist/find/chainMethods.d.ts +0 -16
- package/dist/find/chainMethods.d.ts.map +0 -1
- package/dist/find/chainMethods.js +0 -12
- package/dist/find/chainMethods.js.map +0 -1
- package/dist/find/findMany.d.ts +0 -21
- package/dist/find/findMany.d.ts.map +0 -1
- package/dist/find/findMany.js +0 -152
- package/dist/find/findMany.js.map +0 -1
- package/dist/find/traverseFields.d.ts +0 -17
- package/dist/find/traverseFields.d.ts.map +0 -1
- package/dist/find/traverseFields.js +0 -156
- package/dist/find/traverseFields.js.map +0 -1
- package/dist/find.d.ts +0 -3
- package/dist/find.d.ts.map +0 -1
- package/dist/find.js +0 -21
- package/dist/find.js.map +0 -1
- package/dist/findGlobal.d.ts +0 -3
- package/dist/findGlobal.d.ts.map +0 -1
- package/dist/findGlobal.js +0 -23
- package/dist/findGlobal.js.map +0 -1
- package/dist/findGlobalVersions.d.ts +0 -3
- package/dist/findGlobalVersions.d.ts.map +0 -1
- package/dist/findGlobalVersions.js +0 -24
- package/dist/findGlobalVersions.js.map +0 -1
- package/dist/findOne.d.ts +0 -4
- package/dist/findOne.d.ts.map +0 -1
- package/dist/findOne.js +0 -21
- package/dist/findOne.js.map +0 -1
- package/dist/findVersions.d.ts +0 -3
- package/dist/findVersions.d.ts.map +0 -1
- package/dist/findVersions.js +0 -24
- package/dist/findVersions.js.map +0 -1
- package/dist/init.d.ts +0 -3
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -91
- package/dist/init.js.map +0 -1
- package/dist/migrate.d.ts +0 -3
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -99
- package/dist/migrate.js.map +0 -1
- package/dist/migrateDown.d.ts +0 -3
- package/dist/migrateDown.d.ts.map +0 -1
- package/dist/migrateDown.js +0 -63
- package/dist/migrateDown.js.map +0 -1
- package/dist/migrateFresh.d.ts +0 -8
- package/dist/migrateFresh.d.ts.map +0 -1
- package/dist/migrateFresh.js +0 -72
- package/dist/migrateFresh.js.map +0 -1
- package/dist/migrateRefresh.d.ts +0 -6
- package/dist/migrateRefresh.d.ts.map +0 -1
- package/dist/migrateRefresh.js +0 -102
- package/dist/migrateRefresh.js.map +0 -1
- package/dist/migrateReset.d.ts +0 -6
- package/dist/migrateReset.d.ts.map +0 -1
- package/dist/migrateReset.js +0 -82
- package/dist/migrateReset.js.map +0 -1
- package/dist/migrateStatus.d.ts +0 -3
- package/dist/migrateStatus.d.ts.map +0 -1
- package/dist/migrateStatus.js +0 -44
- package/dist/migrateStatus.js.map +0 -1
- package/dist/queries/buildAndOrConditions.d.ts +0 -16
- package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
- package/dist/queries/buildAndOrConditions.js +0 -28
- package/dist/queries/buildAndOrConditions.js.map +0 -1
- package/dist/queries/buildQuery.d.ts +0 -30
- package/dist/queries/buildQuery.d.ts.map +0 -1
- package/dist/queries/buildQuery.js +0 -72
- package/dist/queries/buildQuery.js.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
- package/dist/queries/createJSONQuery/index.d.ts +0 -10
- package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/index.js +0 -54
- package/dist/queries/createJSONQuery/index.js.map +0 -1
- package/dist/queries/getTableColumnFromPath.d.ts +0 -50
- package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
- package/dist/queries/getTableColumnFromPath.js +0 -516
- package/dist/queries/getTableColumnFromPath.js.map +0 -1
- package/dist/queries/operatorMap.d.ts +0 -18
- package/dist/queries/operatorMap.d.ts.map +0 -1
- package/dist/queries/operatorMap.js +0 -24
- package/dist/queries/operatorMap.js.map +0 -1
- package/dist/queries/parseParams.d.ts +0 -16
- package/dist/queries/parseParams.d.ts.map +0 -1
- package/dist/queries/parseParams.js +0 -183
- package/dist/queries/parseParams.js.map +0 -1
- package/dist/queries/sanitizeQueryValue.d.ts +0 -15
- package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
- package/dist/queries/sanitizeQueryValue.js +0 -89
- package/dist/queries/sanitizeQueryValue.js.map +0 -1
- package/dist/queries/selectDistinct.d.ts +0 -22
- package/dist/queries/selectDistinct.d.ts.map +0 -1
- package/dist/queries/selectDistinct.js +0 -30
- package/dist/queries/selectDistinct.js.map +0 -1
- package/dist/queryDrafts.d.ts +0 -3
- package/dist/queryDrafts.d.ts.map +0 -1
- package/dist/queryDrafts.js +0 -40
- package/dist/queryDrafts.js.map +0 -1
- package/dist/schema/build.d.ts +0 -34
- package/dist/schema/build.d.ts.map +0 -1
- package/dist/schema/build.js +0 -369
- package/dist/schema/build.js.map +0 -1
- package/dist/schema/createIndex.d.ts +0 -12
- package/dist/schema/createIndex.d.ts.map +0 -1
- package/dist/schema/createIndex.js +0 -18
- package/dist/schema/createIndex.js.map +0 -1
- package/dist/schema/createTableName.d.ts +0 -30
- package/dist/schema/createTableName.d.ts.map +0 -1
- package/dist/schema/createTableName.js +0 -31
- package/dist/schema/createTableName.js.map +0 -1
- package/dist/schema/idToUUID.d.ts +0 -3
- package/dist/schema/idToUUID.d.ts.map +0 -1
- package/dist/schema/idToUUID.js +0 -11
- package/dist/schema/idToUUID.js.map +0 -1
- package/dist/schema/parentIDColumnMap.d.ts +0 -4
- package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
- package/dist/schema/parentIDColumnMap.js +0 -9
- package/dist/schema/parentIDColumnMap.js.map +0 -1
- package/dist/schema/setColumnID.d.ts +0 -11
- package/dist/schema/setColumnID.d.ts.map +0 -1
- package/dist/schema/setColumnID.js +0 -24
- package/dist/schema/setColumnID.js.map +0 -1
- package/dist/schema/traverseFields.d.ts +0 -36
- package/dist/schema/traverseFields.d.ts.map +0 -1
- package/dist/schema/traverseFields.js +0 -614
- package/dist/schema/traverseFields.js.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
- package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
- package/dist/transactions/beginTransaction.d.ts +0 -3
- package/dist/transactions/beginTransaction.d.ts.map +0 -1
- package/dist/transactions/beginTransaction.js +0 -51
- package/dist/transactions/beginTransaction.js.map +0 -1
- package/dist/transactions/commitTransaction.d.ts +0 -3
- package/dist/transactions/commitTransaction.d.ts.map +0 -1
- package/dist/transactions/commitTransaction.js +0 -15
- package/dist/transactions/commitTransaction.js.map +0 -1
- package/dist/transactions/rollbackTransaction.d.ts +0 -3
- package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
- package/dist/transactions/rollbackTransaction.js +0 -14
- package/dist/transactions/rollbackTransaction.js.map +0 -1
- package/dist/transform/read/hasManyNumber.d.ts +0 -10
- package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
- package/dist/transform/read/hasManyNumber.js +0 -10
- package/dist/transform/read/hasManyNumber.js.map +0 -1
- package/dist/transform/read/hasManyText.d.ts +0 -10
- package/dist/transform/read/hasManyText.d.ts.map +0 -1
- package/dist/transform/read/hasManyText.js +0 -10
- package/dist/transform/read/hasManyText.js.map +0 -1
- package/dist/transform/read/index.d.ts +0 -13
- package/dist/transform/read/index.d.ts.map +0 -1
- package/dist/transform/read/index.js +0 -44
- package/dist/transform/read/index.js.map +0 -1
- package/dist/transform/read/relationship.d.ts +0 -10
- package/dist/transform/read/relationship.d.ts.map +0 -1
- package/dist/transform/read/relationship.js +0 -60
- package/dist/transform/read/relationship.js.map +0 -1
- package/dist/transform/read/traverseFields.d.ts +0 -57
- package/dist/transform/read/traverseFields.d.ts.map +0 -1
- package/dist/transform/read/traverseFields.js +0 -435
- package/dist/transform/read/traverseFields.js.map +0 -1
- package/dist/transform/write/array.d.ts +0 -26
- package/dist/transform/write/array.d.ts.map +0 -1
- package/dist/transform/write/array.js +0 -58
- package/dist/transform/write/array.js.map +0 -1
- package/dist/transform/write/blocks.d.ts +0 -25
- package/dist/transform/write/blocks.d.ts.map +0 -1
- package/dist/transform/write/blocks.js +0 -54
- package/dist/transform/write/blocks.js.map +0 -1
- package/dist/transform/write/index.d.ts +0 -13
- package/dist/transform/write/index.d.ts.map +0 -1
- package/dist/transform/write/index.js +0 -41
- package/dist/transform/write/index.js.map +0 -1
- package/dist/transform/write/numbers.d.ts +0 -8
- package/dist/transform/write/numbers.d.ts.map +0 -1
- package/dist/transform/write/numbers.js +0 -11
- package/dist/transform/write/numbers.js.map +0 -1
- package/dist/transform/write/relationships.d.ts +0 -10
- package/dist/transform/write/relationships.d.ts.map +0 -1
- package/dist/transform/write/relationships.js +0 -23
- package/dist/transform/write/relationships.js.map +0 -1
- package/dist/transform/write/selects.d.ts +0 -8
- package/dist/transform/write/selects.d.ts.map +0 -1
- package/dist/transform/write/selects.js +0 -20
- package/dist/transform/write/selects.js.map +0 -1
- package/dist/transform/write/texts.d.ts +0 -8
- package/dist/transform/write/texts.d.ts.map +0 -1
- package/dist/transform/write/texts.js +0 -11
- package/dist/transform/write/texts.js.map +0 -1
- package/dist/transform/write/traverseFields.d.ts +0 -50
- package/dist/transform/write/traverseFields.d.ts.map +0 -1
- package/dist/transform/write/traverseFields.js +0 -445
- package/dist/transform/write/traverseFields.js.map +0 -1
- package/dist/transform/write/types.d.ts +0 -43
- package/dist/transform/write/types.d.ts.map +0 -1
- package/dist/transform/write/types.js +0 -3
- package/dist/transform/write/types.js.map +0 -1
- package/dist/update.d.ts +0 -3
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js +0 -54
- package/dist/update.js.map +0 -1
- package/dist/updateGlobal.d.ts +0 -4
- package/dist/updateGlobal.d.ts.map +0 -1
- package/dist/updateGlobal.js +0 -25
- package/dist/updateGlobal.js.map +0 -1
- package/dist/updateGlobalVersion.d.ts +0 -4
- package/dist/updateGlobalVersion.d.ts.map +0 -1
- package/dist/updateGlobalVersion.js +0 -36
- package/dist/updateGlobalVersion.js.map +0 -1
- package/dist/updateVersion.d.ts +0 -4
- package/dist/updateVersion.d.ts.map +0 -1
- package/dist/updateVersion.js +0 -36
- package/dist/updateVersion.js.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
- package/dist/upsertRow/index.d.ts +0 -4
- package/dist/upsertRow/index.d.ts.map +0 -1
- package/dist/upsertRow/index.js +0 -281
- package/dist/upsertRow/index.js.map +0 -1
- package/dist/upsertRow/insertArrays.d.ts +0 -13
- package/dist/upsertRow/insertArrays.d.ts.map +0 -1
- package/dist/upsertRow/insertArrays.js +0 -68
- package/dist/upsertRow/insertArrays.js.map +0 -1
- package/dist/upsertRow/types.d.ts +0 -32
- package/dist/upsertRow/types.d.ts.map +0 -1
- package/dist/upsertRow/types.js +0 -3
- package/dist/upsertRow/types.js.map +0 -1
- package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
- package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
- package/dist/utilities/appendPrefixToKeys.js +0 -6
- package/dist/utilities/appendPrefixToKeys.js.map +0 -1
- package/dist/utilities/createBlocksMap.d.ts +0 -5
- package/dist/utilities/createBlocksMap.d.ts.map +0 -1
- package/dist/utilities/createBlocksMap.js +0 -29
- package/dist/utilities/createBlocksMap.js.map +0 -1
- package/dist/utilities/createMigrationTable.d.ts +0 -3
- package/dist/utilities/createMigrationTable.d.ts.map +0 -1
- package/dist/utilities/createMigrationTable.js +0 -13
- package/dist/utilities/createMigrationTable.js.map +0 -1
- package/dist/utilities/createRelationshipMap.d.ts +0 -2
- package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
- package/dist/utilities/createRelationshipMap.js +0 -19
- package/dist/utilities/createRelationshipMap.js.map +0 -1
- package/dist/utilities/hasLocalesTable.d.ts +0 -3
- package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
- package/dist/utilities/hasLocalesTable.js +0 -11
- package/dist/utilities/hasLocalesTable.js.map +0 -1
- package/dist/utilities/isArrayOfRows.d.ts +0 -2
- package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
- package/dist/utilities/isArrayOfRows.js +0 -5
- package/dist/utilities/isArrayOfRows.js.map +0 -1
- package/dist/utilities/migrationTableExists.d.ts +0 -3
- package/dist/utilities/migrationTableExists.d.ts.map +0 -1
- package/dist/utilities/migrationTableExists.js +0 -9
- package/dist/utilities/migrationTableExists.js.map +0 -1
- package/dist/utilities/parseError.d.ts +0 -5
- package/dist/utilities/parseError.d.ts.map +0 -1
- package/dist/utilities/parseError.js +0 -17
- package/dist/utilities/parseError.js.map +0 -1
- package/dist/utilities/pushDevSchema.d.ts +0 -9
- package/dist/utilities/pushDevSchema.d.ts.map +0 -1
- package/dist/utilities/pushDevSchema.js +0 -58
- package/dist/utilities/pushDevSchema.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/schema/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Relation } from 'drizzle-orm'\nimport type { IndexBuilder, PgColumnBuilder } from 'drizzle-orm/pg-core'\nimport type { Field, TabAsField } from 'payload'\n\nimport { relations } from 'drizzle-orm'\nimport {\n PgNumericBuilder,\n PgUUIDBuilder,\n PgVarcharBuilder,\n boolean,\n foreignKey,\n index,\n integer,\n jsonb,\n numeric,\n pgEnum,\n text,\n timestamp,\n varchar,\n} from 'drizzle-orm/pg-core'\nimport { InvalidConfiguration } from 'payload'\nimport { fieldAffectsData, optionIsObject } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { GenericColumns, IDType, PostgresAdapter } from '../types.js'\nimport type { BaseExtraConfig, RelationMap } from './build.js'\n\nimport { hasLocalesTable } from '../utilities/hasLocalesTable.js'\nimport { buildTable } from './build.js'\nimport { createIndex } from './createIndex.js'\nimport { createTableName } from './createTableName.js'\nimport { idToUUID } from './idToUUID.js'\nimport { parentIDColumnMap } from './parentIDColumnMap.js'\nimport { validateExistingBlockIsIdentical } from './validateExistingBlockIsIdentical.js'\n\ntype Args = {\n adapter: PostgresAdapter\n columnPrefix?: string\n columns: Record<string, PgColumnBuilder>\n disableNotNull: boolean\n disableUnique?: boolean\n fieldPrefix?: string\n fields: (Field | TabAsField)[]\n forceLocalized?: boolean\n indexes: Record<string, (cols: GenericColumns) => IndexBuilder>\n localesColumns: Record<string, PgColumnBuilder>\n localesIndexes: Record<string, (cols: GenericColumns) => IndexBuilder>\n newTableName: string\n parentTableName: string\n relationsToBuild: RelationMap\n relationships: Set<string>\n rootRelationsToBuild?: RelationMap\n rootTableIDColType: string\n rootTableName: string\n versions: 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 columnPrefix,\n columns,\n disableNotNull,\n disableUnique = false,\n fieldPrefix,\n fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\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 if (columns.id instanceof PgUUIDBuilder) parentIDColType = 'uuid'\n if (columns.id instanceof PgNumericBuilder) parentIDColType = 'numeric'\n if (columns.id instanceof PgVarcharBuilder) parentIDColType = 'varchar'\n\n fields.forEach((field) => {\n if ('name' in field && field.name === 'id') return\n let columnName: string\n let fieldName: string\n\n let targetTable = columns\n let targetIndexes = indexes\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${field.name[0] === '_' ? '_' : ''}${toSnakeCase(\n field.name,\n )}`\n fieldName = `${fieldPrefix?.replace('.', '_') || ''}${field.name}`\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 (field.localized || forceLocalized) &&\n field.type !== 'array' &&\n field.type !== 'blocks' &&\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) &&\n !['array', 'blocks', 'group', 'point', 'relationship', 'upload'].includes(field.type) &&\n !('hasMany' in field && field.hasMany === true)\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 targetIndexes[`${newTableName}_${field.name}Idx`] = createIndex({\n name: fieldName,\n columnName,\n tableName: newTableName,\n unique,\n })\n }\n }\n\n switch (field.type) {\n case 'text': {\n if (field.hasMany) {\n if (field.localized) {\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] = varchar(columnName)\n }\n break\n }\n case 'email':\n case 'code':\n case 'textarea': {\n targetTable[fieldName] = varchar(columnName)\n break\n }\n\n case 'number': {\n if (field.hasMany) {\n if (field.localized) {\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] = numeric(columnName)\n }\n break\n }\n\n case 'richText':\n case 'json': {\n targetTable[fieldName] = jsonb(columnName)\n break\n }\n\n case 'date': {\n targetTable[fieldName] = timestamp(columnName, {\n mode: 'string',\n precision: 3,\n withTimezone: true,\n })\n break\n }\n\n case 'point': {\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 adapter.enums[enumName] = pgEnum(\n enumName,\n field.options.map((option) => {\n if (optionIsObject(option)) {\n return option.value\n }\n\n return option\n }) as [string, ...string[]],\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 const baseColumns: Record<string, PgColumnBuilder> = {\n order: integer('order').notNull(),\n parent: parentIDColumnMap[parentIDColType]('parent_id').notNull(),\n value: adapter.enums[enumName]('value'),\n }\n\n const baseExtraConfig: BaseExtraConfig = {\n orderIdx: (cols) => index(`${selectTableName}_order_idx`).on(cols.order),\n parentFk: (cols) =>\n foreignKey({\n name: `${selectTableName}_parent_fk`,\n columns: [cols.parent],\n foreignColumns: [adapter.tables[parentTableName].id],\n }).onDelete('cascade'),\n parentIdx: (cols) => index(`${selectTableName}_parent_idx`).on(cols.parent),\n }\n\n if (field.localized) {\n baseColumns.locale = adapter.enums.enum__locales('locale').notNull()\n baseExtraConfig.localeIdx = (cols) =>\n index(`${selectTableName}_locale_idx`).on(cols.locale)\n }\n\n if (field.index) {\n baseExtraConfig.value = (cols) => index(`${selectTableName}_value_idx`).on(cols.value)\n }\n\n buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull,\n disableUnique,\n fields: [],\n rootTableName,\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.relations[`relations_${selectTableName}`] = relations(\n adapter.tables[selectTableName],\n ({ one }) => ({\n parent: one(adapter.tables[parentTableName], {\n fields: [adapter.tables[selectTableName].parent],\n references: [adapter.tables[parentTableName].id],\n relationName: fieldName,\n }),\n }),\n )\n } else {\n targetTable[fieldName] = adapter.enums[enumName](fieldName)\n }\n break\n }\n\n case 'checkbox': {\n targetTable[fieldName] = boolean(columnName)\n break\n }\n\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, PgColumnBuilder> = {\n _order: integer('_order').notNull(),\n _parentID: parentIDColumnMap[parentIDColType]('_parent_id').notNull(),\n }\n\n const baseExtraConfig: BaseExtraConfig = {\n _orderIdx: (cols) => index(`${arrayTableName}_order_idx`).on(cols._order),\n _parentIDFk: (cols) =>\n foreignKey({\n name: `${arrayTableName}_parent_id_fk`,\n columns: [cols['_parentID']],\n foreignColumns: [adapter.tables[parentTableName].id],\n }).onDelete('cascade'),\n _parentIDIdx: (cols) => index(`${arrayTableName}_parent_id_idx`).on(cols._parentID),\n }\n\n if (field.localized && adapter.payload.config.localization) {\n baseColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n baseExtraConfig._localeIdx = (cols) =>\n index(`${arrayTableName}_locale_idx`).on(cols._locale)\n }\n\n const {\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fields: disableUnique ? idToUUID(field.fields) : field.fields,\n rootRelationsToBuild,\n rootRelationships: relationships,\n rootTableIDColType,\n rootTableName,\n tableName: arrayTableName,\n versions,\n })\n\n if (subHasManyTextField) {\n if (!hasManyTextField || subHasManyTextField === 'index')\n hasManyTextField = subHasManyTextField\n }\n if (subHasManyNumberField) {\n if (!hasManyNumberField || subHasManyNumberField === 'index')\n hasManyNumberField = subHasManyNumberField\n }\n\n relationsToBuild.set(fieldName, {\n type: 'many',\n // arrays have their own localized table, independent of the base table.\n localized: false,\n target: arrayTableName,\n })\n\n adapter.relations[`relations_${arrayTableName}`] = relations(\n adapter.tables[arrayTableName],\n ({ many, one }) => {\n const result: Record<string, Relation<string>> = {\n _parentID: one(adapter.tables[parentTableName], {\n fields: [adapter.tables[arrayTableName]._parentID],\n references: [adapter.tables[parentTableName].id],\n relationName: fieldName,\n }),\n }\n\n if (hasLocalesTable(field.fields)) {\n result._locales = many(adapter.tables[`${arrayTableName}${adapter.localesSuffix}`], {\n relationName: '_locales',\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 result[key] = one(adapter.tables[target], {\n fields: [adapter.tables[arrayWithLocalized][key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], { relationName: key })\n }\n })\n\n return result\n },\n )\n\n break\n }\n\n case 'blocks': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n field.blocks.forEach((block) => {\n const blockTableName = createTableName({\n adapter,\n config: block,\n parentTableName: rootTableName,\n prefix: `${rootTableName}_blocks_`,\n throwValidationError,\n versionsCustomName: versions,\n })\n if (!adapter.tables[blockTableName]) {\n const baseColumns: Record<string, PgColumnBuilder> = {\n _order: integer('_order').notNull(),\n _parentID: parentIDColumnMap[rootTableIDColType]('_parent_id').notNull(),\n _path: text('_path').notNull(),\n }\n\n const baseExtraConfig: BaseExtraConfig = {\n _orderIdx: (cols) => index(`${blockTableName}_order_idx`).on(cols._order),\n _parentIDIdx: (cols) => index(`${blockTableName}_parent_id_idx`).on(cols._parentID),\n _parentIdFk: (cols) =>\n foreignKey({\n name: `${blockTableName}_parent_id_fk`,\n columns: [cols._parentID],\n foreignColumns: [adapter.tables[rootTableName].id],\n }).onDelete('cascade'),\n _pathIdx: (cols) => index(`${blockTableName}_path_idx`).on(cols._path),\n }\n\n if (field.localized && adapter.payload.config.localization) {\n baseColumns._locale = adapter.enums.enum__locales('_locale').notNull()\n baseExtraConfig._localeIdx = (cols) =>\n index(`${blockTableName}_locale_idx`).on(cols._locale)\n }\n\n const {\n hasManyNumberField: subHasManyNumberField,\n hasManyTextField: subHasManyTextField,\n relationsToBuild: subRelationsToBuild,\n } = buildTable({\n adapter,\n baseColumns,\n baseExtraConfig,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fields: disableUnique ? idToUUID(block.fields) : block.fields,\n rootRelationsToBuild,\n rootRelationships: relationships,\n rootTableIDColType,\n rootTableName,\n tableName: blockTableName,\n versions,\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 adapter.relations[`relations_${blockTableName}`] = relations(\n adapter.tables[blockTableName],\n ({ many, one }) => {\n const result: Record<string, Relation<string>> = {\n _parentID: one(adapter.tables[rootTableName], {\n fields: [adapter.tables[blockTableName]._parentID],\n references: [adapter.tables[rootTableName].id],\n relationName: `_blocks_${block.slug}`,\n }),\n }\n\n if (hasLocalesTable(block.fields)) {\n result._locales = many(\n adapter.tables[`${blockTableName}${adapter.localesSuffix}`],\n { relationName: '_locales' },\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 result[key] = one(adapter.tables[target], {\n fields: [adapter.tables[blockWithLocalized][key]],\n references: [adapter.tables[target].id],\n relationName: key,\n })\n }\n if (type === 'many') {\n result[key] = many(adapter.tables[target], { relationName: key })\n }\n })\n\n return result\n },\n )\n } else if (process.env.NODE_ENV !== 'production' && !versions) {\n validateExistingBlockIsIdentical({\n block,\n localized: field.localized,\n rootTableName,\n table: adapter.tables[blockTableName],\n tableLocales: adapter.tables[`${blockTableName}${adapter.localesSuffix}`],\n })\n }\n // blocks relationships are defined from the collection or globals table down to the block, bypassing any subBlocks\n rootRelationsToBuild.set(`_blocks_${block.slug}`, {\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\n case 'tab':\n case 'group': {\n if (!('name' in field)) {\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 columnPrefix,\n columns,\n disableNotNull,\n disableUnique,\n fieldPrefix,\n fields: field.fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (groupHasLocalizedField) hasLocalizedField = true\n if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (groupHasManyTextField) hasManyTextField = true\n if (groupHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (groupHasManyNumberField) hasManyNumberField = true\n if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\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 columnPrefix: `${columnName}_`,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix: `${fieldName}.`,\n fields: field.fields,\n forceLocalized: field.localized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName: `${parentTableName}_${columnName}`,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (groupHasLocalizedField) hasLocalizedField = true\n if (groupHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (groupHasManyTextField) hasManyTextField = true\n if (groupHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (groupHasManyNumberField) hasManyNumberField = true\n if (groupHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'tabs': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n\n const {\n hasLocalizedField: tabHasLocalizedField,\n hasLocalizedManyNumberField: tabHasLocalizedManyNumberField,\n hasLocalizedManyTextField: tabHasLocalizedManyTextField,\n hasLocalizedRelationshipField: tabHasLocalizedRelationshipField,\n hasManyNumberField: tabHasManyNumberField,\n hasManyTextField: tabHasManyTextField,\n } = traverseFields({\n adapter,\n columnPrefix,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (tabHasLocalizedField) hasLocalizedField = true\n if (tabHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (tabHasManyTextField) hasManyTextField = true\n if (tabHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (tabHasManyNumberField) hasManyNumberField = true\n if (tabHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'row':\n case 'collapsible': {\n const disableNotNullFromHere = Boolean(field.admin?.condition) || disableNotNull\n const {\n hasLocalizedField: rowHasLocalizedField,\n hasLocalizedManyNumberField: rowHasLocalizedManyNumberField,\n hasLocalizedManyTextField: rowHasLocalizedManyTextField,\n hasLocalizedRelationshipField: rowHasLocalizedRelationshipField,\n hasManyNumberField: rowHasManyNumberField,\n hasManyTextField: rowHasManyTextField,\n } = traverseFields({\n adapter,\n columnPrefix,\n columns,\n disableNotNull: disableNotNullFromHere,\n disableUnique,\n fieldPrefix,\n fields: field.fields,\n forceLocalized,\n indexes,\n localesColumns,\n localesIndexes,\n newTableName,\n parentTableName,\n relationsToBuild,\n relationships,\n rootRelationsToBuild,\n rootTableIDColType,\n rootTableName,\n versions,\n })\n\n if (rowHasLocalizedField) hasLocalizedField = true\n if (rowHasLocalizedRelationshipField) hasLocalizedRelationshipField = true\n if (rowHasManyTextField) hasManyTextField = true\n if (rowHasLocalizedManyTextField) hasLocalizedManyTextField = true\n if (rowHasManyNumberField) hasManyNumberField = true\n if (rowHasLocalizedManyNumberField) hasLocalizedManyNumberField = true\n break\n }\n\n case 'relationship':\n case 'upload':\n if (Array.isArray(field.relationTo)) {\n field.relationTo.forEach((relation) => relationships.add(relation))\n } else if (field.type === 'relationship' && field.hasMany) {\n relationships.add(field.relationTo)\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 = adapter.idType === 'uuid' ? 'uuid' : 'integer'\n const relatedCollectionCustomID = relationshipConfig.fields.find(\n (field) => fieldAffectsData(field) && field.name === 'id',\n )\n if (relatedCollectionCustomID?.type === 'number') colType = 'numeric'\n if (relatedCollectionCustomID?.type === 'text') colType = 'varchar'\n\n // make the foreign key column for relationship using the correct id column type\n targetTable[fieldName] = parentIDColumnMap[colType](`${columnName}_id`).references(\n () => adapter.tables[tableName].id,\n { onDelete: 'set null' },\n )\n\n // add relationship to table\n relationsToBuild.set(fieldName, {\n type: 'one',\n localized: adapter.payload.config.localization && field.localized,\n target: tableName,\n })\n\n // add notNull when not required\n if (!disableNotNull && field.required && !field.admin?.condition) {\n targetTable[fieldName].notNull()\n }\n break\n }\n if (adapter.payload.config.localization && field.localized) {\n hasLocalizedRelationshipField = true\n }\n\n break\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()\n }\n })\n\n return {\n hasLocalizedField,\n hasLocalizedManyNumberField,\n hasLocalizedManyTextField,\n hasLocalizedRelationshipField,\n hasManyNumberField,\n hasManyTextField,\n }\n}\n"],"names":["relations","PgNumericBuilder","PgUUIDBuilder","PgVarcharBuilder","boolean","foreignKey","index","integer","jsonb","numeric","pgEnum","text","timestamp","varchar","InvalidConfiguration","fieldAffectsData","optionIsObject","toSnakeCase","hasLocalesTable","buildTable","createIndex","createTableName","idToUUID","parentIDColumnMap","validateExistingBlockIsIdentical","traverseFields","adapter","columnPrefix","columns","disableNotNull","disableUnique","fieldPrefix","fields","forceLocalized","indexes","localesColumns","localesIndexes","newTableName","parentTableName","relationsToBuild","relationships","rootRelationsToBuild","rootTableIDColType","rootTableName","versions","throwValidationError","hasLocalizedField","hasLocalizedRelationshipField","hasManyTextField","hasLocalizedManyTextField","hasManyNumberField","hasLocalizedManyNumberField","parentIDColType","id","forEach","field","name","columnName","fieldName","targetTable","targetIndexes","replace","payload","config","localization","localized","type","hasMany","unique","includes","constraintValue","fieldConstraints","tableName","mode","precision","withTimezone","enumName","prefix","target","enums","options","map","option","value","selectTableName","versionsCustomName","baseColumns","order","notNull","parent","baseExtraConfig","orderIdx","cols","on","parentFk","foreignColumns","tables","onDelete","parentIdx","locale","enum__locales","localeIdx","set","one","references","relationName","disableNotNullFromHere","Boolean","admin","condition","arrayTableName","_order","_parentID","_orderIdx","_parentIDFk","_parentIDIdx","_locale","_localeIdx","subHasManyNumberField","subHasManyTextField","subRelationsToBuild","rootRelationships","many","result","_locales","localesSuffix","key","arrayWithLocalized","blocks","block","blockTableName","_path","_parentIdFk","_pathIdx","slug","blockWithLocalized","process","env","NODE_ENV","table","tableLocales","groupHasLocalizedField","groupHasLocalizedManyNumberField","groupHasLocalizedManyTextField","groupHasLocalizedRelationshipField","groupHasManyNumberField","groupHasManyTextField","tabHasLocalizedField","tabHasLocalizedManyNumberField","tabHasLocalizedManyTextField","tabHasLocalizedRelationshipField","tabHasManyNumberField","tabHasManyTextField","tabs","tab","rowHasLocalizedField","rowHasLocalizedManyNumberField","rowHasLocalizedManyTextField","rowHasLocalizedRelationshipField","rowHasManyNumberField","rowHasManyTextField","Array","isArray","relationTo","relation","add","relationshipConfig","collections","tableNameMap","get","colType","idType","relatedCollectionCustomID","find","required"],"mappings":"AAAA,oCAAoC,GAKpC,SAASA,SAAS,QAAQ,cAAa;AACvC,SACEC,gBAAgB,EAChBC,aAAa,EACbC,gBAAgB,EAChBC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,SAAS,EACTC,OAAO,QACF,sBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,UAAS;AAC9C,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,iBAAgB;AACjE,OAAOC,iBAAiB,gBAAe;AAKvC,SAASC,eAAe,QAAQ,kCAAiC;AACjE,SAASC,UAAU,QAAQ,aAAY;AACvC,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,QAAQ,QAAQ,gBAAe;AACxC,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,gCAAgC,QAAQ,wCAAuC;AAiCxF,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,YAAY,EACZC,OAAO,EACPC,cAAc,EACdC,gBAAgB,KAAK,EACrBC,WAAW,EACXC,MAAM,E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;oBAChF/G,WAAW,CAACD,UAAU,GAAGnC,iBAAiB,CAACmJ,QAAQ,CAAC,CAAC,EAAEjH,WAAW,GAAG,CAAC,EAAE+C,UAAU,CAChF,IAAM9E,QAAQsE,MAAM,CAACxB,UAAU,CAACnB,EAAE,EAClC;wBAAE4C,UAAU;oBAAW;oBAGzB,4BAA4B;oBAC5B1D,iBAAiB+D,GAAG,CAAC5C,WAAW;wBAC9BQ,MAAM;wBACND,WAAWvC,QAAQoC,OAAO,CAACC,MAAM,CAACC,YAAY,IAAIT,MAAMU,SAAS;wBACjEa,QAAQN;oBACV;oBAEA,gCAAgC;oBAChC,IAAI,CAAC3C,kBAAkB0B,MAAMuH,QAAQ,IAAI,CAACvH,MAAMqD,KAAK,EAAEC,WAAW;wBAChElD,WAAW,CAACD,UAAU,CAAC8B,OAAO;oBAChC;oBACA;gBACF;gBACA,IAAI9D,QAAQoC,OAAO,CAACC,MAAM,CAACC,YAAY,IAAIT,MAAMU,SAAS,EAAE;oBAC1DlB,gCAAgC;gBAClC;gBAEA;YAEF;gBACE;QACJ;QAEA,MAAM8D,YAAYtD,MAAMqD,KAAK,IAAIrD,MAAMqD,KAAK,CAACC,SAAS;QAEtD,IACE,CAAChF,kBACD8B,WAAW,CAACD,UAAU,IACtB,cAAcH,SACdA,MAAMuH,QAAQ,IACd,CAACjE,WACD;YACAlD,WAAW,CAACD,UAAU,CAAC8B,OAAO;QAChC;IACF;IAEA,OAAO;QACL1C;QACAK;QACAF;QACAF;QACAG;QACAF;IACF;AACF,EAAC"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import type { Block } from 'payload';
|
2
|
-
import type { GenericTable } from '../types.js';
|
3
|
-
type Args = {
|
4
|
-
block: Block;
|
5
|
-
localized: boolean;
|
6
|
-
rootTableName: string;
|
7
|
-
table: GenericTable;
|
8
|
-
tableLocales?: GenericTable;
|
9
|
-
};
|
10
|
-
export declare const validateExistingBlockIsIdentical: ({ block, localized, rootTableName, table, tableLocales, }: Args) => void;
|
11
|
-
export {};
|
12
|
-
//# sourceMappingURL=validateExistingBlockIsIdentical.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"validateExistingBlockIsIdentical.d.ts","sourceRoot":"","sources":["../../src/schema/validateExistingBlockIsIdentical.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAS,MAAM,SAAS,CAAA;AAK3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,YAAY,CAAA;IACnB,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B,CAAA;AAkDD,eAAO,MAAM,gCAAgC,8DAM1C,IAAI,KAAG,IA+BT,CAAA"}
|
@@ -1,76 +0,0 @@
|
|
1
|
-
import { InvalidConfiguration } from 'payload';
|
2
|
-
import { fieldAffectsData, fieldHasSubFields, tabHasName } from 'payload/shared';
|
3
|
-
const getFlattenedFieldNames = (fields, prefix = '')=>{
|
4
|
-
return fields.reduce((fieldsToUse, field)=>{
|
5
|
-
let fieldPrefix = prefix;
|
6
|
-
if ([
|
7
|
-
'array',
|
8
|
-
'blocks',
|
9
|
-
'relationship',
|
10
|
-
'upload'
|
11
|
-
].includes(field.type) || 'hasMany' in field && field.hasMany === true) {
|
12
|
-
return fieldsToUse;
|
13
|
-
}
|
14
|
-
if (fieldHasSubFields(field)) {
|
15
|
-
fieldPrefix = 'name' in field ? `${prefix}${field.name}_` : prefix;
|
16
|
-
return [
|
17
|
-
...fieldsToUse,
|
18
|
-
...getFlattenedFieldNames(field.fields, fieldPrefix)
|
19
|
-
];
|
20
|
-
}
|
21
|
-
if (field.type === 'tabs') {
|
22
|
-
return [
|
23
|
-
...fieldsToUse,
|
24
|
-
...field.tabs.reduce((tabFields, tab)=>{
|
25
|
-
fieldPrefix = 'name' in tab ? `${prefix}_${tab.name}` : prefix;
|
26
|
-
return [
|
27
|
-
...tabFields,
|
28
|
-
...tabHasName(tab) ? [
|
29
|
-
{
|
30
|
-
...tab,
|
31
|
-
type: 'tab'
|
32
|
-
}
|
33
|
-
] : getFlattenedFieldNames(tab.fields, fieldPrefix)
|
34
|
-
];
|
35
|
-
}, [])
|
36
|
-
];
|
37
|
-
}
|
38
|
-
if (fieldAffectsData(field)) {
|
39
|
-
return [
|
40
|
-
...fieldsToUse,
|
41
|
-
{
|
42
|
-
name: `${fieldPrefix}${field.name}`,
|
43
|
-
localized: field.localized
|
44
|
-
}
|
45
|
-
];
|
46
|
-
}
|
47
|
-
return fieldsToUse;
|
48
|
-
}, []);
|
49
|
-
};
|
50
|
-
export const validateExistingBlockIsIdentical = ({ block, localized, rootTableName, table, tableLocales })=>{
|
51
|
-
const fieldNames = getFlattenedFieldNames(block.fields);
|
52
|
-
const missingField = // ensure every field from the config is in the matching table
|
53
|
-
fieldNames.find(({ name, localized })=>{
|
54
|
-
const fieldTable = localized && tableLocales ? tableLocales : table;
|
55
|
-
return Object.keys(fieldTable).indexOf(name) === -1;
|
56
|
-
}) || // ensure every table column is matched for every field from the config
|
57
|
-
Object.keys(table).find((fieldName)=>{
|
58
|
-
if (![
|
59
|
-
'_locale',
|
60
|
-
'_order',
|
61
|
-
'_parentID',
|
62
|
-
'_path',
|
63
|
-
'_uuid'
|
64
|
-
].includes(fieldName)) {
|
65
|
-
return fieldNames.findIndex((field)=>field.name) === -1;
|
66
|
-
}
|
67
|
-
});
|
68
|
-
if (missingField) {
|
69
|
-
throw new InvalidConfiguration(`The table ${rootTableName} has multiple blocks with slug ${block.slug}, but the schemas do not match. One block includes the field ${typeof missingField === 'string' ? missingField : missingField.name}, while the other block does not.`);
|
70
|
-
}
|
71
|
-
if (Boolean(localized) !== Boolean(table._locale)) {
|
72
|
-
throw new InvalidConfiguration(`The table ${rootTableName} has multiple blocks with slug ${block.slug}, but the schemas do not match. One is localized, but another is not. Block schemas of the same name must match exactly.`);
|
73
|
-
}
|
74
|
-
};
|
75
|
-
|
76
|
-
//# sourceMappingURL=validateExistingBlockIsIdentical.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/schema/validateExistingBlockIsIdentical.ts"],"sourcesContent":["import type { Block, Field } from 'payload'\n\nimport { InvalidConfiguration } from 'payload'\nimport { fieldAffectsData, fieldHasSubFields, tabHasName } from 'payload/shared'\n\nimport type { GenericTable } from '../types.js'\n\ntype Args = {\n block: Block\n localized: boolean\n rootTableName: string\n table: GenericTable\n tableLocales?: GenericTable\n}\n\nconst getFlattenedFieldNames = (\n fields: Field[],\n prefix: string = '',\n): { localized?: boolean; name: string }[] => {\n return fields.reduce((fieldsToUse, field) => {\n let fieldPrefix = prefix\n\n if (\n ['array', 'blocks', 'relationship', 'upload'].includes(field.type) ||\n ('hasMany' in field && field.hasMany === true)\n ) {\n return fieldsToUse\n }\n\n if (fieldHasSubFields(field)) {\n fieldPrefix = 'name' in field ? `${prefix}${field.name}_` : prefix\n return [...fieldsToUse, ...getFlattenedFieldNames(field.fields, fieldPrefix)]\n }\n\n if (field.type === 'tabs') {\n return [\n ...fieldsToUse,\n ...field.tabs.reduce((tabFields, tab) => {\n fieldPrefix = 'name' in tab ? `${prefix}_${tab.name}` : prefix\n return [\n ...tabFields,\n ...(tabHasName(tab)\n ? [{ ...tab, type: 'tab' }]\n : getFlattenedFieldNames(tab.fields, fieldPrefix)),\n ]\n }, []),\n ]\n }\n\n if (fieldAffectsData(field)) {\n return [\n ...fieldsToUse,\n {\n name: `${fieldPrefix}${field.name}`,\n localized: field.localized,\n },\n ]\n }\n\n return fieldsToUse\n }, [])\n}\n\nexport const validateExistingBlockIsIdentical = ({\n block,\n localized,\n rootTableName,\n table,\n tableLocales,\n}: Args): void => {\n const fieldNames = getFlattenedFieldNames(block.fields)\n\n const missingField =\n // ensure every field from the config is in the matching table\n fieldNames.find(({ name, localized }) => {\n const fieldTable = localized && tableLocales ? tableLocales : table\n return Object.keys(fieldTable).indexOf(name) === -1\n }) ||\n // ensure every table column is matched for every field from the config\n Object.keys(table).find((fieldName) => {\n if (!['_locale', '_order', '_parentID', '_path', '_uuid'].includes(fieldName)) {\n return fieldNames.findIndex((field) => field.name) === -1\n }\n })\n\n if (missingField) {\n throw new InvalidConfiguration(\n `The table ${rootTableName} has multiple blocks with slug ${\n block.slug\n }, but the schemas do not match. One block includes the field ${\n typeof missingField === 'string' ? missingField : missingField.name\n }, while the other block does not.`,\n )\n }\n\n if (Boolean(localized) !== Boolean(table._locale)) {\n throw new InvalidConfiguration(\n `The table ${rootTableName} has multiple blocks with slug ${block.slug}, but the schemas do not match. One is localized, but another is not. Block schemas of the same name must match exactly.`,\n )\n }\n}\n"],"names":["InvalidConfiguration","fieldAffectsData","fieldHasSubFields","tabHasName","getFlattenedFieldNames","fields","prefix","reduce","fieldsToUse","field","fieldPrefix","includes","type","hasMany","name","tabs","tabFields","tab","localized","validateExistingBlockIsIdentical","block","rootTableName","table","tableLocales","fieldNames","missingField","find","fieldTable","Object","keys","indexOf","fieldName","findIndex","slug","Boolean","_locale"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,UAAS;AAC9C,SAASC,gBAAgB,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,iBAAgB;AAYhF,MAAMC,yBAAyB,CAC7BC,QACAC,SAAiB,EAAE;IAEnB,OAAOD,OAAOE,MAAM,CAAC,CAACC,aAAaC;QACjC,IAAIC,cAAcJ;QAElB,IACE;YAAC;YAAS;YAAU;YAAgB;SAAS,CAACK,QAAQ,CAACF,MAAMG,IAAI,KAChE,aAAaH,SAASA,MAAMI,OAAO,KAAK,MACzC;YACA,OAAOL;QACT;QAEA,IAAIN,kBAAkBO,QAAQ;YAC5BC,cAAc,UAAUD,QAAQ,CAAC,EAAEH,OAAO,EAAEG,MAAMK,IAAI,CAAC,CAAC,CAAC,GAAGR;YAC5D,OAAO;mBAAIE;mBAAgBJ,uB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AChB,MAAM,IAAIzB,qBACR,CAAC,UAAU,EAAEqB,cAAc,+BAA+B,EACxDD,MAAMa,IAAI,CACX,6DAA6D,EAC5D,OAAOR,iBAAiB,WAAWA,eAAeA,aAAaX,IAAI,CACpE,iCAAiC,CAAC;IAEvC;IAEA,IAAIoB,QAAQhB,eAAegB,QAAQZ,MAAMa,OAAO,GAAG;QACjD,MAAM,IAAInC,qBACR,CAAC,UAAU,EAAEqB,cAAc,+BAA+B,EAAED,MAAMa,IAAI,CAAC,wHAAwH,CAAC;IAEpM;AACF,EAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"beginTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/beginTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM/C,eAAO,MAAM,gBAAgB,EAAE,gBA2D9B,CAAA"}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import { v4 as uuid } from 'uuid';
|
2
|
-
export const beginTransaction = async function beginTransaction() {
|
3
|
-
let id;
|
4
|
-
try {
|
5
|
-
id = uuid();
|
6
|
-
let reject;
|
7
|
-
let resolve;
|
8
|
-
let transaction;
|
9
|
-
let transactionReady;
|
10
|
-
// Await initialization here
|
11
|
-
// Prevent race conditions where the adapter may be
|
12
|
-
// re-initializing, and `this.drizzle` is potentially undefined
|
13
|
-
await this.initializing;
|
14
|
-
// Drizzle only exposes a transactions API that is sufficient if you
|
15
|
-
// can directly pass around the `tx` argument. But our operations are spread
|
16
|
-
// over many files and we don't want to pass the `tx` around like that,
|
17
|
-
// so instead, we "lift" up the `resolve` and `reject` methods
|
18
|
-
// and will call them in our respective transaction methods
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
20
|
-
const done = this.drizzle.transaction(async (tx)=>{
|
21
|
-
transaction = tx;
|
22
|
-
await new Promise((res, rej)=>{
|
23
|
-
resolve = ()=>{
|
24
|
-
res();
|
25
|
-
return done;
|
26
|
-
};
|
27
|
-
reject = ()=>{
|
28
|
-
rej();
|
29
|
-
return done;
|
30
|
-
};
|
31
|
-
transactionReady();
|
32
|
-
});
|
33
|
-
}).catch(()=>{
|
34
|
-
// swallow
|
35
|
-
});
|
36
|
-
// Need to wait until the transaction is ready
|
37
|
-
// before binding its `resolve` and `reject` methods below
|
38
|
-
await new Promise((resolve)=>transactionReady = resolve);
|
39
|
-
this.sessions[id] = {
|
40
|
-
db: transaction,
|
41
|
-
reject,
|
42
|
-
resolve
|
43
|
-
};
|
44
|
-
} catch (err) {
|
45
|
-
this.payload.logger.error(`Error: cannot begin transaction: ${err.message}`, err);
|
46
|
-
process.exit(1);
|
47
|
-
}
|
48
|
-
return id;
|
49
|
-
};
|
50
|
-
|
51
|
-
//# sourceMappingURL=beginTransaction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/beginTransaction.ts"],"sourcesContent":["import type { BeginTransaction } from 'payload'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { DrizzleTransaction, PostgresAdapter } from '../types.js'\n\nexport const beginTransaction: BeginTransaction = async function beginTransaction(\n this: PostgresAdapter,\n) {\n let id\n try {\n id = uuid()\n\n let reject: () => Promise<void>\n let resolve: () => Promise<void>\n let transaction: DrizzleTransaction\n\n let transactionReady: () => void\n\n // Await initialization here\n // Prevent race conditions where the adapter may be\n // re-initializing, and `this.drizzle` is potentially undefined\n await this.initializing\n\n // Drizzle only exposes a transactions API that is sufficient if you\n // can directly pass around the `tx` argument. But our operations are spread\n // over many files and we don't want to pass the `tx` around like that,\n // so instead, we \"lift\" up the `resolve` and `reject` methods\n // and will call them in our respective transaction methods\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n const done = this.drizzle\n .transaction(async (tx) => {\n transaction = tx\n await new Promise<void>((res, rej) => {\n resolve = () => {\n res()\n return done\n }\n reject = () => {\n rej()\n return done\n }\n transactionReady()\n })\n })\n .catch(() => {\n // swallow\n })\n\n // Need to wait until the transaction is ready\n // before binding its `resolve` and `reject` methods below\n await new Promise<void>((resolve) => (transactionReady = resolve))\n\n this.sessions[id] = {\n db: transaction,\n reject,\n resolve,\n }\n } catch (err) {\n this.payload.logger.error(`Error: cannot begin transaction: ${err.message}`, err)\n process.exit(1)\n }\n\n return id\n}\n"],"names":["v4","uuid","beginTransaction","id","reject","resolve","transaction","transactionReady","initializing","done","drizzle","tx","Promise","res","rej","catch","sessions","db","err","payload","logger","error","message","process","exit"],"mappings":"AAEA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,OAAO,MAAMC,mBAAqC,eAAeA;IAG/D,IAAIC;IACJ,IAAI;QACFA,KAAKF;QAEL,IAAIG;QACJ,IAAIC;QACJ,IAAIC;QAEJ,IAAIC;QAEJ,4BAA4B;QAC5B,mDAAmD;QACnD,+DAA+D;QAC/D,MAAM,IAAI,CAACC,YAAY;QAEvB,oEAAoE;QACpE,4EAA4E;QAC5E,uEAAuE;QACvE,8DAA8D;QAC9D,2DAA2D;QAE3D,mEAAmE;QACnE,MAAMC,OAAO,IAAI,CAACC,OAAO,CACtBJ,WAAW,CAAC,OAAOK;YAClBL,cAAcK;YACd,MAAM,IAAIC,QAAc,CAACC,KAAKC;gBAC5BT,UAAU;oBACRQ;oBACA,OAAOJ;gBACT;gBACAL,SAAS;oBACPU;oBACA,OAAOL;gBACT;gBACAF;YACF;QACF,GACCQ,KAAK,CAAC;QACL,UAAU;QACZ;QAEF,8CAA8C;QAC9C,0DAA0D;QAC1D,MAAM,IAAIH,QAAc,CAACP,UAAaE,mBAAmBF;QAEzD,IAAI,CAACW,QAAQ,CAACb,GAAG,GAAG;YAClBc,IAAIX;YACJF;YACAC;QACF;IACF,EAAE,OAAOa,KAAK;QACZ,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,iCAAiC,EAAEH,IAAII,OAAO,CAAC,CAAC,EAAEJ;QAC7EK,QAAQC,IAAI,CAAC;IACf;IAEA,OAAOrB;AACT,EAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,iBAe/B,CAAA"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
export const commitTransaction = async function commitTransaction(id) {
|
2
|
-
if (id instanceof Promise) return;
|
3
|
-
// if the session was deleted it has already been aborted
|
4
|
-
if (!this.sessions[id]) {
|
5
|
-
return;
|
6
|
-
}
|
7
|
-
try {
|
8
|
-
await this.sessions[id].resolve();
|
9
|
-
} catch (err) {
|
10
|
-
await this.sessions[id].reject();
|
11
|
-
}
|
12
|
-
delete this.sessions[id];
|
13
|
-
};
|
14
|
-
|
15
|
-
//# sourceMappingURL=commitTransaction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(id) {\n if (id instanceof Promise) return\n\n // if the session was deleted it has already been aborted\n if (!this.sessions[id]) {\n return\n }\n\n try {\n await this.sessions[id].resolve()\n } catch (err: unknown) {\n await this.sessions[id].reject()\n }\n\n delete this.sessions[id]\n}\n"],"names":["commitTransaction","id","Promise","sessions","resolve","err","reject"],"mappings":"AAEA,OAAO,MAAMA,oBAAuC,eAAeA,kBAAkBC,EAAE;IACrF,IAAIA,cAAcC,SAAS;IAE3B,yDAAyD;IACzD,IAAI,CAAC,IAAI,CAACC,QAAQ,CAACF,GAAG,EAAE;QACtB;IACF;IAEA,IAAI;QACF,MAAM,IAAI,CAACE,QAAQ,CAACF,GAAG,CAACG,OAAO;IACjC,EAAE,OAAOC,KAAc;QACrB,MAAM,IAAI,CAACF,QAAQ,CAACF,GAAG,CAACK,MAAM;IAChC;IAEA,OAAO,IAAI,CAACH,QAAQ,CAACF,GAAG;AAC1B,EAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD,eAAO,MAAM,mBAAmB,EAAE,mBAgBjC,CAAA"}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
export const rollbackTransaction = async function rollbackTransaction(incomingID = '') {
|
2
|
-
const transactionID = incomingID instanceof Promise ? await incomingID : incomingID;
|
3
|
-
// if multiple operations are using the same transaction, the first will flow through and delete the session.
|
4
|
-
// subsequent calls should be ignored.
|
5
|
-
if (!this.sessions[transactionID]) {
|
6
|
-
return;
|
7
|
-
}
|
8
|
-
// end the session promise in failure by calling reject
|
9
|
-
await this.sessions[transactionID].reject();
|
10
|
-
// delete the session causing any other operations with the same transaction to fail
|
11
|
-
delete this.sessions[transactionID];
|
12
|
-
};
|
13
|
-
|
14
|
-
//# sourceMappingURL=rollbackTransaction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[transactionID]) {\n return\n }\n\n // end the session promise in failure by calling reject\n await this.sessions[transactionID].reject()\n\n // delete the session causing any other operations with the same transaction to fail\n delete this.sessions[transactionID]\n}\n"],"names":["rollbackTransaction","incomingID","transactionID","Promise","sessions","reject"],"mappings":"AAEA,OAAO,MAAMA,sBAA2C,eAAeA,oBACrEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,uDAAuD;IACvD,MAAM,IAAI,CAACE,QAAQ,CAACF,cAAc,CAACG,MAAM;IAEzC,oFAAoF;IACpF,OAAO,IAAI,CAACD,QAAQ,CAACF,cAAc;AACrC,EAAC"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { NumberField } from 'payload';
|
2
|
-
type Args = {
|
3
|
-
field: NumberField;
|
4
|
-
locale?: string;
|
5
|
-
numberRows: Record<string, unknown>[];
|
6
|
-
ref: Record<string, unknown>;
|
7
|
-
};
|
8
|
-
export declare const transformHasManyNumber: ({ field, locale, numberRows, ref }: Args) => void;
|
9
|
-
export {};
|
10
|
-
//# sourceMappingURL=hasManyNumber.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hasManyNumber.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyNumber.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,WAAW,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACrC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,sBAAsB,uCAAwC,IAAI,SAQ9E,CAAA"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ export const transformHasManyNumber = ({ field, locale, numberRows, ref })=>{
|
2
|
-
const result = numberRows.map(({ number })=>number);
|
3
|
-
if (locale) {
|
4
|
-
ref[field.name][locale] = result;
|
5
|
-
} else {
|
6
|
-
ref[field.name] = result;
|
7
|
-
}
|
8
|
-
};
|
9
|
-
|
10
|
-
//# sourceMappingURL=hasManyNumber.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/hasManyNumber.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { NumberField } from 'payload'\n\ntype Args = {\n field: NumberField\n locale?: string\n numberRows: Record<string, unknown>[]\n ref: Record<string, unknown>\n}\n\nexport const transformHasManyNumber = ({ field, locale, numberRows, ref }: Args) => {\n const result = numberRows.map(({ number }) => number)\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyNumber","field","locale","numberRows","ref","result","map","number","name"],"mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,yBAAyB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,UAAU,EAAEC,GAAG,EAAQ;IAC7E,MAAMC,SAASF,WAAWG,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAE,GAAKA;IAE9C,IAAIL,QAAQ;QACVE,GAAG,CAACH,MAAMO,IAAI,CAAC,CAACN,OAAO,GAAGG;IAC5B,OAAO;QACLD,GAAG,CAACH,MAAMO,IAAI,CAAC,GAAGH;IACpB;AACF,EAAC"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { TextField } from 'payload';
|
2
|
-
type Args = {
|
3
|
-
field: TextField;
|
4
|
-
locale?: string;
|
5
|
-
ref: Record<string, unknown>;
|
6
|
-
textRows: Record<string, unknown>[];
|
7
|
-
};
|
8
|
-
export declare const transformHasManyText: ({ field, locale, ref, textRows }: Args) => void;
|
9
|
-
export {};
|
10
|
-
//# sourceMappingURL=hasManyText.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hasManyText.d.ts","sourceRoot":"","sources":["../../../src/transform/read/hasManyText.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,oBAAoB,qCAAsC,IAAI,SAQ1E,CAAA"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ export const transformHasManyText = ({ field, locale, ref, textRows })=>{
|
2
|
-
const result = textRows.map(({ text })=>text);
|
3
|
-
if (locale) {
|
4
|
-
ref[field.name][locale] = result;
|
5
|
-
} else {
|
6
|
-
ref[field.name] = result;
|
7
|
-
}
|
8
|
-
};
|
9
|
-
|
10
|
-
//# sourceMappingURL=hasManyText.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/hasManyText.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { TextField } from 'payload'\n\ntype Args = {\n field: TextField\n locale?: string\n ref: Record<string, unknown>\n textRows: Record<string, unknown>[]\n}\n\nexport const transformHasManyText = ({ field, locale, ref, textRows }: Args) => {\n const result = textRows.map(({ text }) => text)\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformHasManyText","field","locale","ref","textRows","result","map","text","name"],"mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,uBAAuB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQ,EAAQ;IACzE,MAAMC,SAASD,SAASE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA;IAE1C,IAAIL,QAAQ;QACVC,GAAG,CAACF,MAAMO,IAAI,CAAC,CAACN,OAAO,GAAGG;IAC5B,OAAO;QACLF,GAAG,CAACF,MAAMO,IAAI,CAAC,GAAGH;IACpB;AACF,EAAC"}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import type { Field, SanitizedConfig, TypeWithID } from 'payload';
|
2
|
-
import type { PostgresAdapter } from '../../types.js';
|
3
|
-
type TransformArgs = {
|
4
|
-
adapter: PostgresAdapter;
|
5
|
-
config: SanitizedConfig;
|
6
|
-
data: Record<string, unknown>;
|
7
|
-
fallbackLocale?: false | string;
|
8
|
-
fields: Field[];
|
9
|
-
locale?: string;
|
10
|
-
};
|
11
|
-
export declare const transform: <T extends Record<string, unknown> | TypeWithID>({ adapter, config, data, fields, }: TransformArgs) => T;
|
12
|
-
export {};
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/read/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAID,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,sCAKrE,aAAa,KAAG,CA2ClB,CAAA"}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ import { createBlocksMap } from '../../utilities/createBlocksMap.js';
|
2
|
-
import { createPathMap } from '../../utilities/createRelationshipMap.js';
|
3
|
-
import { traverseFields } from './traverseFields.js';
|
4
|
-
// This is the entry point to transform Drizzle output data
|
5
|
-
// into the shape Payload expects based on field schema
|
6
|
-
export const transform = ({ adapter, config, data, fields })=>{
|
7
|
-
let relationships = {};
|
8
|
-
let texts = {};
|
9
|
-
let numbers = {};
|
10
|
-
if ('_rels' in data) {
|
11
|
-
relationships = createPathMap(data._rels);
|
12
|
-
delete data._rels;
|
13
|
-
}
|
14
|
-
if ('_texts' in data) {
|
15
|
-
texts = createPathMap(data._texts);
|
16
|
-
delete data._texts;
|
17
|
-
}
|
18
|
-
if ('_numbers' in data) {
|
19
|
-
numbers = createPathMap(data._numbers);
|
20
|
-
delete data._numbers;
|
21
|
-
}
|
22
|
-
const blocks = createBlocksMap(data);
|
23
|
-
const deletions = [];
|
24
|
-
const result = traverseFields({
|
25
|
-
adapter,
|
26
|
-
blocks,
|
27
|
-
config,
|
28
|
-
dataRef: {
|
29
|
-
id: data.id
|
30
|
-
},
|
31
|
-
deletions,
|
32
|
-
fieldPrefix: '',
|
33
|
-
fields,
|
34
|
-
numbers,
|
35
|
-
path: '',
|
36
|
-
relationships,
|
37
|
-
table: data,
|
38
|
-
texts
|
39
|
-
});
|
40
|
-
deletions.forEach((deletion)=>deletion());
|
41
|
-
return result;
|
42
|
-
};
|
43
|
-
|
44
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/index.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field, SanitizedConfig, TypeWithID } from 'payload'\n\nimport type { PostgresAdapter } from '../../types.js'\n\nimport { createBlocksMap } from '../../utilities/createBlocksMap.js'\nimport { createPathMap } from '../../utilities/createRelationshipMap.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype TransformArgs = {\n adapter: PostgresAdapter\n config: SanitizedConfig\n data: Record<string, unknown>\n fallbackLocale?: false | string\n fields: Field[]\n locale?: string\n}\n\n// This is the entry point to transform Drizzle output data\n// into the shape Payload expects based on field schema\nexport const transform = <T extends Record<string, unknown> | TypeWithID>({\n adapter,\n config,\n data,\n fields,\n}: TransformArgs): T => {\n let relationships: Record<string, Record<string, unknown>[]> = {}\n let texts: Record<string, Record<string, unknown>[]> = {}\n let numbers: Record<string, Record<string, unknown>[]> = {}\n\n if ('_rels' in data) {\n relationships = createPathMap(data._rels)\n delete data._rels\n }\n\n if ('_texts' in data) {\n texts = createPathMap(data._texts)\n delete data._texts\n }\n\n if ('_numbers' in data) {\n numbers = createPathMap(data._numbers)\n delete data._numbers\n }\n\n const blocks = createBlocksMap(data)\n const deletions = []\n\n const result = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: {\n id: data.id,\n },\n deletions,\n fieldPrefix: '',\n fields,\n numbers,\n path: '',\n relationships,\n table: data,\n texts,\n })\n\n deletions.forEach((deletion) => deletion())\n\n return result\n}\n"],"names":["createBlocksMap","createPathMap","traverseFields","transform","adapter","config","data","fields","relationships","texts","numbers","_rels","_texts","_numbers","blocks","deletions","result","dataRef","id","fieldPrefix","path","table","forEach","deletion"],"mappings":"AAAA,oCAAoC,GAKpC,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,2CAA0C;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAWpD,2DAA2D;AAC3D,uDAAuD;AACvD,OAAO,MAAMC,YAAY,CAAiD,EACxEC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,MAAM,EACQ;IACd,IAAIC,gBAA2D,CAAC;IAChE,IAAIC,QAAmD,CAAC;IACxD,IAAIC,UAAqD,CAAC;IAE1D,IAAI,WAAWJ,MAAM;QACnBE,gBAAgBP,cAAcK,KAAKK,KAAK;QACxC,OAAOL,KAAKK,KAAK;IACnB;IAEA,IAAI,YAAYL,MAAM;QACpBG,QAAQR,cAAcK,KAAKM,MAAM;QACjC,OAAON,KAAKM,MAAM;IACpB;IAEA,IAAI,cAAcN,MAAM;QACtBI,UAAUT,cAAcK,KAAKO,QAAQ;QACrC,OAAOP,KAAKO,QAAQ;IACtB;IAEA,MAAMC,SAASd,gBAAgBM;IAC/B,MAAMS,YAAY,EAAE;IAEpB,MAAMC,SAASd,eAAkB;QAC/BE;QACAU;QACAT;QACAY,SAAS;YACPC,IAAIZ,KAAKY,EAAE;QACb;QACAH;QACAI,aAAa;QACbZ;QACAG;QACAU,MAAM;QACNZ;QACAa,OAAOf;QACPG;IACF;IAEAM,UAAUO,OAAO,CAAC,CAACC,WAAaA;IAEhC,OAAOP;AACT,EAAC"}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { RelationshipField, UploadField } from 'payload';
|
2
|
-
type Args = {
|
3
|
-
field: RelationshipField | UploadField;
|
4
|
-
locale?: string;
|
5
|
-
ref: Record<string, unknown>;
|
6
|
-
relations: Record<string, unknown>[];
|
7
|
-
};
|
8
|
-
export declare const transformRelationship: ({ field, locale, ref, relations }: Args) => void;
|
9
|
-
export {};
|
10
|
-
//# sourceMappingURL=relationship.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"relationship.d.ts","sourceRoot":"","sources":["../../../src/transform/read/relationship.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE7D,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAAA;IACtC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACrC,CAAA;AAED,eAAO,MAAM,qBAAqB,sCAAuC,IAAI,SA6D5E,CAAA"}
|
@@ -1,60 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ export const transformRelationship = ({ field, locale, ref, relations })=>{
|
2
|
-
let result;
|
3
|
-
if (!('hasMany' in field) || field.hasMany === false) {
|
4
|
-
const relation = relations[0];
|
5
|
-
if (relation) {
|
6
|
-
// Handle hasOne Poly
|
7
|
-
if (Array.isArray(field.relationTo)) {
|
8
|
-
const matchedRelation = Object.entries(relation).find(([key, val])=>val !== null && ![
|
9
|
-
'id',
|
10
|
-
'locale',
|
11
|
-
'order',
|
12
|
-
'parent',
|
13
|
-
'path'
|
14
|
-
].includes(key));
|
15
|
-
if (matchedRelation) {
|
16
|
-
const relationTo = matchedRelation[0].replace('ID', '');
|
17
|
-
result = {
|
18
|
-
relationTo,
|
19
|
-
value: matchedRelation[1]
|
20
|
-
};
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
} else {
|
25
|
-
const transformedRelations = [];
|
26
|
-
relations.forEach((relation)=>{
|
27
|
-
// Handle hasMany
|
28
|
-
if (!Array.isArray(field.relationTo)) {
|
29
|
-
const relatedData = relation[`${field.relationTo}ID`];
|
30
|
-
if (relatedData) {
|
31
|
-
transformedRelations.push(relatedData);
|
32
|
-
}
|
33
|
-
} else {
|
34
|
-
// Handle hasMany Poly
|
35
|
-
const matchedRelation = Object.entries(relation).find(([key, val])=>val !== null && ![
|
36
|
-
'id',
|
37
|
-
'locale',
|
38
|
-
'order',
|
39
|
-
'parent',
|
40
|
-
'path'
|
41
|
-
].includes(key));
|
42
|
-
if (matchedRelation) {
|
43
|
-
const relationTo = matchedRelation[0].replace('ID', '');
|
44
|
-
transformedRelations.push({
|
45
|
-
relationTo,
|
46
|
-
value: matchedRelation[1]
|
47
|
-
});
|
48
|
-
}
|
49
|
-
}
|
50
|
-
});
|
51
|
-
result = transformedRelations;
|
52
|
-
}
|
53
|
-
if (locale) {
|
54
|
-
ref[field.name][locale] = result;
|
55
|
-
} else {
|
56
|
-
ref[field.name] = result;
|
57
|
-
}
|
58
|
-
};
|
59
|
-
|
60
|
-
//# sourceMappingURL=relationship.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/relationship.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { RelationshipField, UploadField } from 'payload'\n\ntype Args = {\n field: RelationshipField | UploadField\n locale?: string\n ref: Record<string, unknown>\n relations: Record<string, unknown>[]\n}\n\nexport const transformRelationship = ({ field, locale, ref, relations }: Args) => {\n let result: unknown\n\n if (!('hasMany' in field) || field.hasMany === false) {\n const relation = relations[0]\n\n if (relation) {\n // Handle hasOne Poly\n if (Array.isArray(field.relationTo)) {\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key),\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n result = {\n relationTo,\n value: matchedRelation[1],\n }\n }\n }\n }\n } else {\n const transformedRelations = []\n\n relations.forEach((relation) => {\n // Handle hasMany\n if (!Array.isArray(field.relationTo)) {\n const relatedData = relation[`${field.relationTo}ID`]\n\n if (relatedData) {\n transformedRelations.push(relatedData)\n }\n } else {\n // Handle hasMany Poly\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key),\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n transformedRelations.push({\n relationTo,\n value: matchedRelation[1],\n })\n }\n }\n })\n\n result = transformedRelations\n }\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformRelationship","field","locale","ref","relations","result","hasMany","relation","Array","isArray","relationTo","matchedRelation","Object","entries","find","key","val","includes","replace","value","transformedRelations","forEach","relatedData","push","name"],"mappings":"AAAA,oCAAoC,GAUpC,OAAO,MAAMA,wBAAwB,CAAC,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,SAAS,EAAQ;IAC3E,IAAIC;IAEJ,IAAI,CAAE,CAAA,aAAaJ,KAAI,KAAMA,MAAMK,OAAO,KAAK,OAAO;QACpD,MAAMC,WAAWH,SAAS,CAAC,EAAE;QAE7B,IAAIG,UAAU;YACZ,qBAAqB;YACrB,IAAIC,MAAMC,OAAO,CAACR,MAAMS,UAAU,GAAG;gBACnC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