@payloadcms/db-postgres 3.0.0-canary.6041f49 → 3.0.0-canary.690108d
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/connect.d.ts +1 -1
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +22 -13
- package/dist/connect.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +2 -0
- package/dist/exports/migration-utils.d.ts.map +1 -0
- package/dist/exports/migration-utils.js +3 -0
- package/dist/exports/migration-utils.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -67
- package/dist/index.js.map +1 -1
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.js +211 -0
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.js +6 -0
- package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
- package/dist/types.d.ts +42 -77
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +24 -15
- package/dist/count.d.ts +0 -3
- package/dist/count.d.ts.map +0 -1
- package/dist/count.js +0 -50
- 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 -5
- 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 -6
- 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 -81
- package/dist/createMigration.js.map +0 -1
- package/dist/createVersion.d.ts +0 -5
- package/dist/createVersion.d.ts.map +0 -1
- package/dist/createVersion.js +0 -44
- 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 -11
- package/dist/destroy.js.map +0 -1
- package/dist/find/buildFindManyArgs.d.ts +0 -13
- package/dist/find/buildFindManyArgs.d.ts.map +0 -1
- package/dist/find/buildFindManyArgs.js +0 -64
- 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 -22
- package/dist/find/findMany.d.ts.map +0 -1
- package/dist/find/findMany.js +0 -163
- package/dist/find/findMany.js.map +0 -1
- package/dist/find/traverseFields.d.ts +0 -16
- package/dist/find/traverseFields.d.ts.map +0 -1
- package/dist/find/traverseFields.js +0 -138
- 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 -5
- 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 -96
- 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 -17
- package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
- package/dist/queries/buildAndOrConditions.js +0 -29
- package/dist/queries/buildAndOrConditions.js.map +0 -1
- package/dist/queries/buildQuery.d.ts +0 -31
- package/dist/queries/buildQuery.d.ts.map +0 -1
- package/dist/queries/buildQuery.js +0 -76
- 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 -51
- package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
- package/dist/queries/getTableColumnFromPath.js +0 -445
- 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 -17
- package/dist/queries/parseParams.d.ts.map +0 -1
- package/dist/queries/parseParams.js +0 -182
- 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 -90
- package/dist/queries/sanitizeQueryValue.js.map +0 -1
- package/dist/queries/selectDistinct.d.ts +0 -23
- package/dist/queries/selectDistinct.d.ts.map +0 -1
- package/dist/queries/selectDistinct.js +0 -41
- 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 -41
- package/dist/queryDrafts.js.map +0 -1
- package/dist/schema/build.d.ts +0 -30
- package/dist/schema/build.d.ts.map +0 -1
- package/dist/schema/build.js +0 -320
- 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 -38
- package/dist/schema/traverseFields.d.ts.map +0 -1
- package/dist/schema/traverseFields.js +0 -551
- 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 -47
- 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 -14
- 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 -13
- 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 -12
- package/dist/transform/read/index.d.ts.map +0 -1
- package/dist/transform/read/index.js +0 -43
- 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 -64
- package/dist/transform/read/relationship.js.map +0 -1
- package/dist/transform/read/traverseFields.d.ts +0 -52
- package/dist/transform/read/traverseFields.d.ts.map +0 -1
- package/dist/transform/read/traverseFields.js +0 -421
- 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 -428
- 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 -55
- package/dist/update.js.map +0 -1
- package/dist/updateGlobal.d.ts +0 -5
- 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 -5
- 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 -5
- 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 -277
- 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 -27
- 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,428 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ import { fieldAffectsData } from 'payload/types';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
4
|
-
import { transformArray } from './array.js';
|
5
|
-
import { transformBlocks } from './blocks.js';
|
6
|
-
import { transformNumbers } from './numbers.js';
|
7
|
-
import { transformRelationship } from './relationships.js';
|
8
|
-
import { transformSelects } from './selects.js';
|
9
|
-
import { transformTexts } from './texts.js';
|
10
|
-
export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksToDelete, columnPrefix, data, existingLocales, fieldPrefix, fields, forcedLocale, locales, numbers, parentTableName, path, relationships, relationshipsToDelete, row, selects, texts })=>{
|
11
|
-
fields.forEach((field)=>{
|
12
|
-
let columnName = '';
|
13
|
-
let fieldName = '';
|
14
|
-
let fieldData;
|
15
|
-
if (fieldAffectsData(field)) {
|
16
|
-
columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`;
|
17
|
-
fieldName = `${fieldPrefix || ''}${field.name}`;
|
18
|
-
fieldData = data[field.name];
|
19
|
-
}
|
20
|
-
if (field.type === 'array') {
|
21
|
-
const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
|
22
|
-
if (!arrays[arrayTableName]) arrays[arrayTableName] = [];
|
23
|
-
if (field.localized) {
|
24
|
-
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
25
|
-
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
26
|
-
if (Array.isArray(localeData)) {
|
27
|
-
const newRows = transformArray({
|
28
|
-
adapter,
|
29
|
-
arrayTableName,
|
30
|
-
baseTableName,
|
31
|
-
blocks,
|
32
|
-
blocksToDelete,
|
33
|
-
data: localeData,
|
34
|
-
field,
|
35
|
-
locale: localeKey,
|
36
|
-
numbers,
|
37
|
-
path,
|
38
|
-
relationships,
|
39
|
-
relationshipsToDelete,
|
40
|
-
selects,
|
41
|
-
texts
|
42
|
-
});
|
43
|
-
arrays[arrayTableName] = arrays[arrayTableName].concat(newRows);
|
44
|
-
}
|
45
|
-
});
|
46
|
-
}
|
47
|
-
} else {
|
48
|
-
const newRows = transformArray({
|
49
|
-
adapter,
|
50
|
-
arrayTableName,
|
51
|
-
baseTableName,
|
52
|
-
blocks,
|
53
|
-
blocksToDelete,
|
54
|
-
data: data[field.name],
|
55
|
-
field,
|
56
|
-
numbers,
|
57
|
-
path,
|
58
|
-
relationships,
|
59
|
-
relationshipsToDelete,
|
60
|
-
selects,
|
61
|
-
texts
|
62
|
-
});
|
63
|
-
arrays[arrayTableName] = arrays[arrayTableName].concat(newRows);
|
64
|
-
}
|
65
|
-
return;
|
66
|
-
}
|
67
|
-
if (field.type === 'blocks') {
|
68
|
-
field.blocks.forEach(({ slug })=>{
|
69
|
-
blocksToDelete.add(toSnakeCase(slug));
|
70
|
-
});
|
71
|
-
if (field.localized) {
|
72
|
-
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
73
|
-
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
74
|
-
if (Array.isArray(localeData)) {
|
75
|
-
transformBlocks({
|
76
|
-
adapter,
|
77
|
-
baseTableName,
|
78
|
-
blocks,
|
79
|
-
blocksToDelete,
|
80
|
-
data: localeData,
|
81
|
-
field,
|
82
|
-
locale: localeKey,
|
83
|
-
numbers,
|
84
|
-
path,
|
85
|
-
relationships,
|
86
|
-
relationshipsToDelete,
|
87
|
-
selects,
|
88
|
-
texts
|
89
|
-
});
|
90
|
-
}
|
91
|
-
});
|
92
|
-
}
|
93
|
-
} else if (isArrayOfRows(fieldData)) {
|
94
|
-
transformBlocks({
|
95
|
-
adapter,
|
96
|
-
baseTableName,
|
97
|
-
blocks,
|
98
|
-
blocksToDelete,
|
99
|
-
data: fieldData,
|
100
|
-
field,
|
101
|
-
numbers,
|
102
|
-
path,
|
103
|
-
relationships,
|
104
|
-
relationshipsToDelete,
|
105
|
-
selects,
|
106
|
-
texts
|
107
|
-
});
|
108
|
-
}
|
109
|
-
return;
|
110
|
-
}
|
111
|
-
if (field.type === 'group') {
|
112
|
-
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
113
|
-
if (field.localized) {
|
114
|
-
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
115
|
-
traverseFields({
|
116
|
-
adapter,
|
117
|
-
arrays,
|
118
|
-
baseTableName,
|
119
|
-
blocks,
|
120
|
-
blocksToDelete,
|
121
|
-
columnPrefix: `${columnName}_`,
|
122
|
-
data: localeData,
|
123
|
-
existingLocales,
|
124
|
-
fieldPrefix: `${fieldName}_`,
|
125
|
-
fields: field.fields,
|
126
|
-
forcedLocale: localeKey,
|
127
|
-
locales,
|
128
|
-
numbers,
|
129
|
-
parentTableName,
|
130
|
-
path: `${path || ''}${field.name}.`,
|
131
|
-
relationships,
|
132
|
-
relationshipsToDelete,
|
133
|
-
row,
|
134
|
-
selects,
|
135
|
-
texts
|
136
|
-
});
|
137
|
-
});
|
138
|
-
} else {
|
139
|
-
traverseFields({
|
140
|
-
adapter,
|
141
|
-
arrays,
|
142
|
-
baseTableName,
|
143
|
-
blocks,
|
144
|
-
blocksToDelete,
|
145
|
-
columnPrefix: `${columnName}_`,
|
146
|
-
data: data[field.name],
|
147
|
-
existingLocales,
|
148
|
-
fieldPrefix: `${fieldName}_`,
|
149
|
-
fields: field.fields,
|
150
|
-
locales,
|
151
|
-
numbers,
|
152
|
-
parentTableName,
|
153
|
-
path: `${path || ''}${field.name}.`,
|
154
|
-
relationships,
|
155
|
-
relationshipsToDelete,
|
156
|
-
row,
|
157
|
-
selects,
|
158
|
-
texts
|
159
|
-
});
|
160
|
-
}
|
161
|
-
}
|
162
|
-
return;
|
163
|
-
}
|
164
|
-
if (field.type === 'tabs') {
|
165
|
-
field.tabs.forEach((tab)=>{
|
166
|
-
if ('name' in tab) {
|
167
|
-
if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {
|
168
|
-
if (tab.localized) {
|
169
|
-
Object.entries(data[tab.name]).forEach(([localeKey, localeData])=>{
|
170
|
-
traverseFields({
|
171
|
-
adapter,
|
172
|
-
arrays,
|
173
|
-
baseTableName,
|
174
|
-
blocks,
|
175
|
-
blocksToDelete,
|
176
|
-
columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,
|
177
|
-
data: localeData,
|
178
|
-
existingLocales,
|
179
|
-
fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,
|
180
|
-
fields: tab.fields,
|
181
|
-
forcedLocale: localeKey,
|
182
|
-
locales,
|
183
|
-
numbers,
|
184
|
-
parentTableName,
|
185
|
-
path: `${path || ''}${tab.name}.`,
|
186
|
-
relationships,
|
187
|
-
relationshipsToDelete,
|
188
|
-
row,
|
189
|
-
selects,
|
190
|
-
texts
|
191
|
-
});
|
192
|
-
});
|
193
|
-
} else {
|
194
|
-
traverseFields({
|
195
|
-
adapter,
|
196
|
-
arrays,
|
197
|
-
baseTableName,
|
198
|
-
blocks,
|
199
|
-
blocksToDelete,
|
200
|
-
columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,
|
201
|
-
data: data[tab.name],
|
202
|
-
existingLocales,
|
203
|
-
fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,
|
204
|
-
fields: tab.fields,
|
205
|
-
locales,
|
206
|
-
numbers,
|
207
|
-
parentTableName,
|
208
|
-
path: `${path || ''}${tab.name}.`,
|
209
|
-
relationships,
|
210
|
-
relationshipsToDelete,
|
211
|
-
row,
|
212
|
-
selects,
|
213
|
-
texts
|
214
|
-
});
|
215
|
-
}
|
216
|
-
}
|
217
|
-
} else {
|
218
|
-
traverseFields({
|
219
|
-
adapter,
|
220
|
-
arrays,
|
221
|
-
baseTableName,
|
222
|
-
blocks,
|
223
|
-
blocksToDelete,
|
224
|
-
columnPrefix,
|
225
|
-
data,
|
226
|
-
existingLocales,
|
227
|
-
fieldPrefix,
|
228
|
-
fields: tab.fields,
|
229
|
-
locales,
|
230
|
-
numbers,
|
231
|
-
parentTableName,
|
232
|
-
path,
|
233
|
-
relationships,
|
234
|
-
relationshipsToDelete,
|
235
|
-
row,
|
236
|
-
selects,
|
237
|
-
texts
|
238
|
-
});
|
239
|
-
}
|
240
|
-
});
|
241
|
-
}
|
242
|
-
if (field.type === 'row' || field.type === 'collapsible') {
|
243
|
-
traverseFields({
|
244
|
-
adapter,
|
245
|
-
arrays,
|
246
|
-
baseTableName,
|
247
|
-
blocks,
|
248
|
-
blocksToDelete,
|
249
|
-
columnPrefix,
|
250
|
-
data,
|
251
|
-
existingLocales,
|
252
|
-
fieldPrefix,
|
253
|
-
fields: field.fields,
|
254
|
-
locales,
|
255
|
-
numbers,
|
256
|
-
parentTableName,
|
257
|
-
path,
|
258
|
-
relationships,
|
259
|
-
relationshipsToDelete,
|
260
|
-
row,
|
261
|
-
selects,
|
262
|
-
texts
|
263
|
-
});
|
264
|
-
}
|
265
|
-
if (field.type === 'relationship' || field.type === 'upload') {
|
266
|
-
const relationshipPath = `${path || ''}${field.name}`;
|
267
|
-
if (field.localized) {
|
268
|
-
if (typeof fieldData === 'object') {
|
269
|
-
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
270
|
-
if (localeData === null) {
|
271
|
-
relationshipsToDelete.push({
|
272
|
-
locale: localeKey,
|
273
|
-
path: relationshipPath
|
274
|
-
});
|
275
|
-
return;
|
276
|
-
}
|
277
|
-
transformRelationship({
|
278
|
-
baseRow: {
|
279
|
-
locale: localeKey,
|
280
|
-
path: relationshipPath
|
281
|
-
},
|
282
|
-
data: localeData,
|
283
|
-
field,
|
284
|
-
relationships
|
285
|
-
});
|
286
|
-
});
|
287
|
-
}
|
288
|
-
} else {
|
289
|
-
if (fieldData === null || Array.isArray(fieldData) && fieldData.length === 0) {
|
290
|
-
relationshipsToDelete.push({
|
291
|
-
path: relationshipPath
|
292
|
-
});
|
293
|
-
return;
|
294
|
-
}
|
295
|
-
transformRelationship({
|
296
|
-
baseRow: {
|
297
|
-
path: relationshipPath
|
298
|
-
},
|
299
|
-
data: fieldData,
|
300
|
-
field,
|
301
|
-
relationships
|
302
|
-
});
|
303
|
-
}
|
304
|
-
return;
|
305
|
-
}
|
306
|
-
if (field.type === 'text' && field.hasMany) {
|
307
|
-
const textPath = `${path || ''}${field.name}`;
|
308
|
-
if (field.localized) {
|
309
|
-
if (typeof fieldData === 'object') {
|
310
|
-
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
311
|
-
if (Array.isArray(localeData)) {
|
312
|
-
transformTexts({
|
313
|
-
baseRow: {
|
314
|
-
locale: localeKey,
|
315
|
-
path: textPath
|
316
|
-
},
|
317
|
-
data: localeData,
|
318
|
-
texts
|
319
|
-
});
|
320
|
-
}
|
321
|
-
});
|
322
|
-
}
|
323
|
-
} else if (Array.isArray(fieldData)) {
|
324
|
-
transformTexts({
|
325
|
-
baseRow: {
|
326
|
-
path: textPath
|
327
|
-
},
|
328
|
-
data: fieldData,
|
329
|
-
texts
|
330
|
-
});
|
331
|
-
}
|
332
|
-
return;
|
333
|
-
}
|
334
|
-
if (field.type === 'number' && field.hasMany) {
|
335
|
-
const numberPath = `${path || ''}${field.name}`;
|
336
|
-
if (field.localized) {
|
337
|
-
if (typeof fieldData === 'object') {
|
338
|
-
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
339
|
-
if (Array.isArray(localeData)) {
|
340
|
-
transformNumbers({
|
341
|
-
baseRow: {
|
342
|
-
locale: localeKey,
|
343
|
-
path: numberPath
|
344
|
-
},
|
345
|
-
data: localeData,
|
346
|
-
numbers
|
347
|
-
});
|
348
|
-
}
|
349
|
-
});
|
350
|
-
}
|
351
|
-
} else if (Array.isArray(fieldData)) {
|
352
|
-
transformNumbers({
|
353
|
-
baseRow: {
|
354
|
-
path: numberPath
|
355
|
-
},
|
356
|
-
data: fieldData,
|
357
|
-
numbers
|
358
|
-
});
|
359
|
-
}
|
360
|
-
return;
|
361
|
-
}
|
362
|
-
if (field.type === 'select' && field.hasMany) {
|
363
|
-
const selectTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`);
|
364
|
-
if (!selects[selectTableName]) selects[selectTableName] = [];
|
365
|
-
if (field.localized) {
|
366
|
-
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
367
|
-
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
368
|
-
if (Array.isArray(localeData)) {
|
369
|
-
const newRows = transformSelects({
|
370
|
-
id: data._uuid || data.id,
|
371
|
-
data: localeData,
|
372
|
-
locale: localeKey
|
373
|
-
});
|
374
|
-
selects[selectTableName] = selects[selectTableName].concat(newRows);
|
375
|
-
}
|
376
|
-
});
|
377
|
-
}
|
378
|
-
} else if (Array.isArray(data[field.name])) {
|
379
|
-
const newRows = transformSelects({
|
380
|
-
id: data._uuid || data.id,
|
381
|
-
data: data[field.name]
|
382
|
-
});
|
383
|
-
selects[selectTableName] = selects[selectTableName].concat(newRows);
|
384
|
-
}
|
385
|
-
return;
|
386
|
-
}
|
387
|
-
if (fieldAffectsData(field)) {
|
388
|
-
const valuesToTransform = [];
|
389
|
-
if (field.localized) {
|
390
|
-
if (typeof fieldData === 'object' && fieldData !== null) {
|
391
|
-
Object.entries(fieldData).forEach(([localeKey, localeData])=>{
|
392
|
-
if (!locales[localeKey]) locales[localeKey] = {};
|
393
|
-
valuesToTransform.push({
|
394
|
-
localeKey,
|
395
|
-
ref: locales,
|
396
|
-
value: localeData
|
397
|
-
});
|
398
|
-
});
|
399
|
-
}
|
400
|
-
} else {
|
401
|
-
let ref = row;
|
402
|
-
if (forcedLocale) {
|
403
|
-
if (!locales[forcedLocale]) locales[forcedLocale] = {};
|
404
|
-
ref = locales[forcedLocale];
|
405
|
-
}
|
406
|
-
valuesToTransform.push({
|
407
|
-
ref,
|
408
|
-
value: fieldData
|
409
|
-
});
|
410
|
-
}
|
411
|
-
valuesToTransform.forEach(({ localeKey, ref, value })=>{
|
412
|
-
if (typeof value !== 'undefined') {
|
413
|
-
let formattedValue = value;
|
414
|
-
if (field.type === 'date' && field.name === 'updatedAt') {
|
415
|
-
formattedValue = new Date().toISOString();
|
416
|
-
}
|
417
|
-
if (localeKey) {
|
418
|
-
ref[localeKey][fieldName] = formattedValue;
|
419
|
-
} else {
|
420
|
-
ref[fieldName] = formattedValue;
|
421
|
-
}
|
422
|
-
}
|
423
|
-
});
|
424
|
-
}
|
425
|
-
});
|
426
|
-
};
|
427
|
-
|
428
|
-
//# sourceMappingURL=traverseFields.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { transformArray } from './array.js'\nimport { transformBlocks } from './blocks.js'\nimport { transformNumbers } from './numbers.js'\nimport { transformRelationship } from './relationships.js'\nimport { transformSelects } from './selects.js'\nimport { transformTexts } from './texts.js'\n\ntype Args = {\n adapter: PostgresAdapter\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n /**\n * This is the name of the base table\n */\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n /**\n * A snake-case field prefix, representing prior fields\n * Ex: my_group_my_named_tab_\n */\n columnPrefix: string\n data: Record<string, unknown>\n existingLocales?: Record<string, unknown>[]\n /**\n * A prefix that will retain camel-case formatting, representing prior fields\n * Ex: myGroup_myNamedTab_\n */\n fieldPrefix: string\n fields: Field[]\n forcedLocale?: string\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n /**\n * This is the name of the parent table\n */\n parentTableName: string\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n}\n\nexport const traverseFields = ({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields,\n forcedLocale,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n}: Args) => {\n fields.forEach((field) => {\n let columnName = ''\n let fieldName = ''\n let fieldData: unknown\n\n if (fieldAffectsData(field)) {\n columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`\n fieldName = `${fieldPrefix || ''}${field.name}`\n fieldData = data[field.name]\n }\n\n if (field.type === 'array') {\n const arrayTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n\n if (!arrays[arrayTableName]) arrays[arrayTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n })\n }\n } else {\n const newRows = transformArray({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data: data[field.name],\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n\n arrays[arrayTableName] = arrays[arrayTableName].concat(newRows)\n }\n\n return\n }\n\n if (field.type === 'blocks') {\n field.blocks.forEach(({ slug }) => {\n blocksToDelete.add(toSnakeCase(slug))\n })\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: localeData,\n field,\n locale: localeKey,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n })\n }\n } else if (isArrayOfRows(fieldData)) {\n transformBlocks({\n adapter,\n baseTableName,\n blocks,\n blocksToDelete,\n data: fieldData,\n field,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'group') {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n if (field.localized) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnName}_`,\n data: data[field.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldName}_`,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${field.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n if ('name' in tab) {\n if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {\n if (tab.localized) {\n Object.entries(data[tab.name]).forEach(([localeKey, localeData]) => {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: localeData as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n forcedLocale: localeKey,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n })\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,\n data: data[tab.name] as Record<string, unknown>,\n existingLocales,\n fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path: `${path || ''}${tab.name}.`,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n }\n } else {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: tab.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n })\n }\n\n if (field.type === 'row' || field.type === 'collapsible') {\n traverseFields({\n adapter,\n arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix,\n data,\n existingLocales,\n fieldPrefix,\n fields: field.fields,\n locales,\n numbers,\n parentTableName,\n path,\n relationships,\n relationshipsToDelete,\n row,\n selects,\n texts,\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n const relationshipPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (localeData === null) {\n relationshipsToDelete.push({\n locale: localeKey,\n path: relationshipPath,\n })\n return\n }\n\n transformRelationship({\n baseRow: {\n locale: localeKey,\n path: relationshipPath,\n },\n data: localeData,\n field,\n relationships,\n })\n })\n }\n } else {\n if (fieldData === null || (Array.isArray(fieldData) && fieldData.length === 0)) {\n relationshipsToDelete.push({ path: relationshipPath })\n return\n }\n\n transformRelationship({\n baseRow: {\n path: relationshipPath,\n },\n data: fieldData,\n field,\n relationships,\n })\n }\n\n return\n }\n\n if (field.type === 'text' && field.hasMany) {\n const textPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformTexts({\n baseRow: {\n locale: localeKey,\n path: textPath,\n },\n data: localeData,\n texts,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformTexts({\n baseRow: {\n path: textPath,\n },\n data: fieldData,\n texts,\n })\n }\n\n return\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPath = `${path || ''}${field.name}`\n\n if (field.localized) {\n if (typeof fieldData === 'object') {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n transformNumbers({\n baseRow: {\n locale: localeKey,\n path: numberPath,\n },\n data: localeData,\n numbers,\n })\n }\n })\n }\n } else if (Array.isArray(fieldData)) {\n transformNumbers({\n baseRow: {\n path: numberPath,\n },\n data: fieldData,\n numbers,\n })\n }\n\n return\n }\n\n if (field.type === 'select' && field.hasMany) {\n const selectTableName = adapter.tableNameMap.get(`${parentTableName}_${columnName}`)\n if (!selects[selectTableName]) selects[selectTableName] = []\n\n if (field.localized) {\n if (typeof data[field.name] === 'object' && data[field.name] !== null) {\n Object.entries(data[field.name]).forEach(([localeKey, localeData]) => {\n if (Array.isArray(localeData)) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: localeData,\n locale: localeKey,\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n })\n }\n } else if (Array.isArray(data[field.name])) {\n const newRows = transformSelects({\n id: data._uuid || data.id,\n data: data[field.name],\n })\n\n selects[selectTableName] = selects[selectTableName].concat(newRows)\n }\n\n return\n }\n\n if (fieldAffectsData(field)) {\n const valuesToTransform: { localeKey?: string; ref: unknown; value: unknown }[] = []\n\n if (field.localized) {\n if (typeof fieldData === 'object' && fieldData !== null) {\n Object.entries(fieldData).forEach(([localeKey, localeData]) => {\n if (!locales[localeKey]) locales[localeKey] = {}\n\n valuesToTransform.push({\n localeKey,\n ref: locales,\n value: localeData,\n })\n })\n }\n } else {\n let ref = row\n\n if (forcedLocale) {\n if (!locales[forcedLocale]) locales[forcedLocale] = {}\n ref = locales[forcedLocale]\n }\n\n valuesToTransform.push({ ref, value: fieldData })\n }\n\n valuesToTransform.forEach(({ localeKey, ref, value }) => {\n if (typeof value !== 'undefined') {\n let formattedValue = value\n\n if (field.type === 'date' && field.name === 'updatedAt') {\n formattedValue = new Date().toISOString()\n }\n\n if (localeKey) {\n ref[localeKey][fieldName] = formattedValue\n } else {\n ref[fieldName] = formattedValue\n }\n }\n })\n }\n })\n}\n"],"names":["fieldAffectsData","toSnakeCase","isArrayOfRows","transformArray","transformBlocks","transformNumbers","transformRelationship","transformSelects","transformTexts","traverseFields","adapter","arrays","baseTableName","blocks","blocksToDelete","columnPrefix","data","existingLocales","fieldPrefix","fields","forcedLocale","locales","numbers","parentTableName","path","relationships","relationshipsToDelete","row","selects","texts","forEach","field","columnName","fieldName","fieldData","name","type","arrayTableName","tableNameMap","get","localized","Object","entries","localeKey","localeData","Array","isArray","newRows","locale","concat","slug","add","tabs","tab","relationshipPath","push","baseRow","length","hasMany","textPath","numberPath","selectTableName","id","_uuid","valuesToTransform","ref","value","formattedValue","Date","toISOString"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAK,aAAa;wBACvDgC,iBAAiB,IAAIC,OAAOC,WAAW;oBACzC;oBAEA,IAAI1B,WAAW;wBACbsB,GAAG,CAACtB,UAAU,CAACV,UAAU,GAAGkC;oBAC9B,OAAO;wBACLF,GAAG,CAAChC,UAAU,GAAGkC;oBACnB;gBACF;YACF;QACF;IACF;AACF,EAAC"}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
export type ArrayRowToInsert = {
|
2
|
-
arrays: {
|
3
|
-
[tableName: string]: ArrayRowToInsert[];
|
4
|
-
};
|
5
|
-
locales: {
|
6
|
-
[locale: string]: Record<string, unknown>;
|
7
|
-
};
|
8
|
-
row: Record<string, unknown>;
|
9
|
-
};
|
10
|
-
export type BlockRowToInsert = {
|
11
|
-
arrays: {
|
12
|
-
[tableName: string]: ArrayRowToInsert[];
|
13
|
-
};
|
14
|
-
locales: {
|
15
|
-
[locale: string]: Record<string, unknown>;
|
16
|
-
};
|
17
|
-
row: Record<string, unknown>;
|
18
|
-
};
|
19
|
-
export type RelationshipToDelete = {
|
20
|
-
locale?: string;
|
21
|
-
path: string;
|
22
|
-
};
|
23
|
-
export type RowToInsert = {
|
24
|
-
arrays: {
|
25
|
-
[tableName: string]: ArrayRowToInsert[];
|
26
|
-
};
|
27
|
-
blocks: {
|
28
|
-
[blockType: string]: BlockRowToInsert[];
|
29
|
-
};
|
30
|
-
blocksToDelete: Set<string>;
|
31
|
-
locales: {
|
32
|
-
[locale: string]: Record<string, unknown>;
|
33
|
-
};
|
34
|
-
numbers: Record<string, unknown>[];
|
35
|
-
relationships: Record<string, unknown>[];
|
36
|
-
relationshipsToDelete: RelationshipToDelete[];
|
37
|
-
row: Record<string, unknown>;
|
38
|
-
selects: {
|
39
|
-
[tableName: string]: Record<string, unknown>[];
|
40
|
-
};
|
41
|
-
texts: Record<string, unknown>[];
|
42
|
-
};
|
43
|
-
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","source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;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAC/C,CAAA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACjC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/types.ts"],"sourcesContent":["export type ArrayRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type BlockRowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n locales: {\n [locale: string]: Record<string, unknown>\n }\n row: Record<string, unknown>\n}\n\nexport type RelationshipToDelete = {\n locale?: string\n path: string\n}\n\nexport type RowToInsert = {\n arrays: {\n [tableName: string]: ArrayRowToInsert[]\n }\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n locales: {\n [locale: string]: Record<string, unknown>\n }\n numbers: Record<string, unknown>[]\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n row: Record<string, unknown>\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n}\n"],"names":[],"rangeMappings":"","mappings":"AAyBA,WAmBC"}
|
package/dist/update.d.ts
DELETED
package/dist/update.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAUjD,eAAO,MAAM,SAAS,EAAE,SA6CvB,CAAA"}
|
package/dist/update.js
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
import toSnakeCase from 'to-snake-case';
|
2
|
-
import buildQuery from './queries/buildQuery.js';
|
3
|
-
import { selectDistinct } from './queries/selectDistinct.js';
|
4
|
-
import { upsertRow } from './upsertRow/index.js';
|
5
|
-
export const updateOne = async function updateOne({ id, collection: collectionSlug, data, draft, locale, req, where: whereArg }) {
|
6
|
-
const db = this.sessions[req.transactionID]?.db || this.drizzle;
|
7
|
-
const collection = this.payload.collections[collectionSlug].config;
|
8
|
-
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
9
|
-
const whereToUse = whereArg || {
|
10
|
-
id: {
|
11
|
-
equals: id
|
12
|
-
}
|
13
|
-
};
|
14
|
-
let idToUpdate = id;
|
15
|
-
const { joinAliases, joins, selectFields, where } = await buildQuery({
|
16
|
-
adapter: this,
|
17
|
-
fields: collection.fields,
|
18
|
-
locale,
|
19
|
-
tableName,
|
20
|
-
where: whereToUse
|
21
|
-
});
|
22
|
-
const selectDistinctResult = await selectDistinct({
|
23
|
-
adapter: this,
|
24
|
-
chainedMethods: [
|
25
|
-
{
|
26
|
-
args: [
|
27
|
-
1
|
28
|
-
],
|
29
|
-
method: 'limit'
|
30
|
-
}
|
31
|
-
],
|
32
|
-
db,
|
33
|
-
joinAliases,
|
34
|
-
joins,
|
35
|
-
selectFields,
|
36
|
-
tableName,
|
37
|
-
where
|
38
|
-
});
|
39
|
-
if (selectDistinctResult?.[0]?.id) {
|
40
|
-
idToUpdate = selectDistinctResult?.[0]?.id;
|
41
|
-
}
|
42
|
-
const result = await upsertRow({
|
43
|
-
id: idToUpdate,
|
44
|
-
adapter: this,
|
45
|
-
data,
|
46
|
-
db,
|
47
|
-
fields: collection.fields,
|
48
|
-
operation: 'update',
|
49
|
-
req,
|
50
|
-
tableName
|
51
|
-
});
|
52
|
-
return result;
|
53
|
-
};
|
54
|
-
|
55
|
-
//# sourceMappingURL=update.js.map
|
package/dist/update.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/update.ts"],"sourcesContent":["import type { UpdateOne } from 'payload/database'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: PostgresAdapter,\n { id, collection: collectionSlug, data, draft, locale, req, where: whereArg },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n const whereToUse = whereArg || { id: { equals: id } }\n let idToUpdate = id\n\n const { joinAliases, joins, selectFields, where } = await buildQuery({\n adapter: this,\n fields: collection.fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n chainedMethods: [{ args: [1], method: 'limit' }],\n db,\n joinAliases,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n idToUpdate = selectDistinctResult?.[0]?.id\n }\n\n const result = await upsertRow({\n id: idToUpdate,\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'update',\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","buildQuery","selectDistinct","upsertRow","updateOne","id","collection","collectionSlug","data","draft","locale","req","where","whereArg","db","sessions","transactionID","drizzle","payload","collections","config","tableName","tableNameMap","get","slug","whereToUse","equals","idToUpdate","joinAliases","joins","selectFields","adapter","fields","selectDistinctResult","chainedMethods","args","method","result","operation"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,EAAE,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,OAAOC,QAAQ,EAAE;IAE7E,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACJ,IAAIK,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMX,aAAa,IAAI,CAACY,OAAO,CAACC,WAAW,CAACZ,eAAe,CAACa,MAAM;IAClE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACvB,YAAYM,WAAWkB,IAAI;IACnE,MAAMC,aAAaZ,YAAY;QAAER,IAAI;YAAEqB,QAAQrB;QAAG;IAAE;IACpD,IAAIsB,aAAatB;IAEjB,MAAM,EAAEuB,WAAW,EAAEC,KAAK,EAAEC,YAAY,EAAElB,KAAK,EAAE,GAAG,MAAMX,WAAW;QACnE8B,SAAS,IAAI;QACbC,QAAQ1B,WAAW0B,MAAM;QACzBtB;QACAW;QACAT,OAAOa;IACT;IAEA,MAAMQ,uBAAuB,MAAM/B,eAAe;QAChD6B,SAAS,IAAI;QACbG,gBAAgB;YAAC;gBAAEC,MAAM;oBAAC;iBAAE;gBAAEC,QAAQ;YAAQ;SAAE;QAChDtB;QACAc;QACAC;QACAC;QACAT;QACAT;IACF;IAEA,IAAIqB,sBAAsB,CAAC,EAAE,EAAE5B,IAAI;QACjCsB,aAAaM,sBAAsB,CAAC,EAAE,EAAE5B;IAC1C;IAEA,MAAMgC,SAAS,MAAMlC,UAAU;QAC7BE,IAAIsB;QACJI,SAAS,IAAI;QACbvB;QACAM;QACAkB,QAAQ1B,WAAW0B,MAAM;QACzBM,WAAW;QACX3B;QACAU;IACF;IAEA,OAAOgB;AACT,EAAC"}
|
package/dist/updateGlobal.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
import type { UpdateGlobalArgs } from 'payload/database';
|
2
|
-
import type { TypeWithID } from 'payload/types';
|
3
|
-
import type { PostgresAdapter } from './types.js';
|
4
|
-
export declare function updateGlobal<T extends TypeWithID>(this: PostgresAdapter, { slug, data, req }: UpdateGlobalArgs): Promise<T>;
|
5
|
-
//# sourceMappingURL=updateGlobal.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAA0B,UAAU,EAAE,MAAM,eAAe,CAAA;AAIvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,YAAY,CAAC,CAAC,SAAS,UAAU,EACrD,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAkC,EAAE,EAAE,gBAAgB,GACnE,OAAO,CAAC,CAAC,CAAC,CAkBZ"}
|
package/dist/updateGlobal.js
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
import toSnakeCase from 'to-snake-case';
|
2
|
-
import { upsertRow } from './upsertRow/index.js';
|
3
|
-
export async function updateGlobal({ slug, data, req = {} }) {
|
4
|
-
const db = this.sessions[req.transactionID]?.db || this.drizzle;
|
5
|
-
const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
|
6
|
-
const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
|
7
|
-
const existingGlobal = await db.query[tableName].findFirst({});
|
8
|
-
const result = await upsertRow({
|
9
|
-
...existingGlobal ? {
|
10
|
-
id: existingGlobal.id,
|
11
|
-
operation: 'update'
|
12
|
-
} : {
|
13
|
-
operation: 'create'
|
14
|
-
},
|
15
|
-
adapter: this,
|
16
|
-
data,
|
17
|
-
db,
|
18
|
-
fields: globalConfig.fields,
|
19
|
-
req,
|
20
|
-
tableName
|
21
|
-
});
|
22
|
-
return result;
|
23
|
-
}
|
24
|
-
|
25
|
-
//# sourceMappingURL=updateGlobal.js.map
|
package/dist/updateGlobal.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { UpdateGlobalArgs } from 'payload/database'\nimport type { PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function updateGlobal<T extends TypeWithID>(\n this: PostgresAdapter,\n { slug, data, req = {} as PayloadRequestWithData }: UpdateGlobalArgs,\n): Promise<T> {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n const existingGlobal = await db.query[tableName].findFirst({})\n\n const result = await upsertRow<T>({\n ...(existingGlobal ? { id: existingGlobal.id, operation: 'update' } : { operation: 'create' }),\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n req,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","updateGlobal","slug","data","req","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","existingGlobal","query","findFirst","result","id","operation","adapter","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAA2B,EAAoB;IAEpE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKA;IAClF,MAAMY,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACjB,YAAYU,aAAaP,IAAI;IAErE,MAAMe,iBAAiB,MAAMZ,GAAGa,KAAK,CAACJ,UAAU,CAACK,SAAS,CAAC,CAAC;IAE5D,MAAMC,SAAS,MAAMpB,UAAa;QAChC,GAAIiB,iBAAiB;YAAEI,IAAIJ,eAAeI,EAAE;YAAEC,WAAW;QAAS,IAAI;YAAEA,WAAW;QAAS,CAAC;QAC7FC,SAAS,IAAI;QACbpB;QACAE;QACAmB,QAAQf,aAAae,MAAM;QAC3BpB;QACAU;IACF;IAEA,OAAOM;AACT"}
|