@payloadcms/db-postgres 3.0.0-canary.f83d96a → 3.0.0-canary.fb81f02
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 +12 -51
- package/dist/connect.js.map +1 -1
- package/dist/connectionHelpers/nodePostgres.d.ts +11 -0
- package/dist/connectionHelpers/nodePostgres.d.ts.map +1 -0
- package/dist/connectionHelpers/nodePostgres.js +6 -0
- package/dist/connectionHelpers/nodePostgres.js.map +1 -0
- package/dist/countDistinct.d.ts +3 -0
- package/dist/countDistinct.d.ts.map +1 -0
- package/dist/countDistinct.js +24 -0
- package/dist/countDistinct.js.map +1 -0
- package/dist/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
- package/dist/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
- package/dist/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
- package/dist/createJSONQuery/formatJSONPathSegment.js.map +1 -0
- package/dist/createJSONQuery/index.d.ts.map +1 -0
- package/dist/createJSONQuery/index.js.map +1 -0
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +20 -31
- package/dist/createMigration.js.map +1 -1
- package/dist/defaultSnapshot.d.ts +3 -0
- package/dist/defaultSnapshot.d.ts.map +1 -0
- package/dist/defaultSnapshot.js +17 -0
- package/dist/defaultSnapshot.js.map +1 -0
- package/dist/deleteWhere.d.ts +3 -0
- package/dist/deleteWhere.d.ts.map +1 -0
- package/dist/deleteWhere.js +6 -0
- package/dist/deleteWhere.js.map +1 -0
- package/dist/dropDatabase.d.ts +3 -0
- package/dist/dropDatabase.d.ts.map +1 -0
- package/dist/dropDatabase.js +9 -0
- package/dist/dropDatabase.js.map +1 -0
- package/dist/execute.d.ts +3 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +11 -0
- package/dist/execute.js.map +1 -0
- package/dist/getMigrationTemplate.d.ts +4 -0
- package/dist/getMigrationTemplate.d.ts.map +1 -0
- package/dist/getMigrationTemplate.js +13 -0
- package/dist/getMigrationTemplate.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -65
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +2 -10
- package/dist/init.js.map +1 -1
- package/dist/insert.d.ts +3 -0
- package/dist/insert.d.ts.map +1 -0
- package/dist/insert.js +12 -0
- package/dist/insert.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +5 -4
- 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 +2 -2
- 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 +5 -4
- 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/requireDrizzleKit.d.ts +3 -0
- package/dist/requireDrizzleKit.d.ts.map +1 -0
- package/dist/requireDrizzleKit.js +5 -0
- package/dist/requireDrizzleKit.js.map +1 -0
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +2 -2
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/createIndex.d.ts.map +1 -1
- package/dist/schema/createIndex.js +1 -1
- package/dist/schema/createIndex.js.map +1 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +13 -14
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/withDefault.d.ts +4 -0
- package/dist/schema/withDefault.d.ts.map +1 -0
- package/dist/schema/withDefault.js +10 -0
- package/dist/schema/withDefault.js.map +1 -0
- package/dist/types.d.ts +108 -37
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +10 -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 -5
- package/dist/createGlobalVersion.d.ts.map +0 -1
- package/dist/createGlobalVersion.js +0 -33
- package/dist/createGlobalVersion.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/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.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
- package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
- 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/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/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 -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 -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
- /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/convertPathToJSONTraversal.js +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/formatJSONPathSegment.js +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/index.d.ts +0 -0
- /package/dist/{queries/createJSONQuery → createJSONQuery}/index.js +0 -0
@@ -1,435 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ import { fieldAffectsData } from 'payload/shared';
|
2
|
-
import { transformHasManyNumber } from './hasManyNumber.js';
|
3
|
-
import { transformHasManyText } from './hasManyText.js';
|
4
|
-
import { transformRelationship } from './relationship.js';
|
5
|
-
// Traverse fields recursively, transforming data
|
6
|
-
// for each field type into required Payload shape
|
7
|
-
export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts })=>{
|
8
|
-
const sanitizedPath = path ? `${path}.` : path;
|
9
|
-
const formatted = fields.reduce((result, field)=>{
|
10
|
-
if (field.type === 'tabs') {
|
11
|
-
traverseFields({
|
12
|
-
adapter,
|
13
|
-
blocks,
|
14
|
-
config,
|
15
|
-
dataRef,
|
16
|
-
deletions,
|
17
|
-
fieldPrefix,
|
18
|
-
fields: field.tabs.map((tab)=>({
|
19
|
-
...tab,
|
20
|
-
type: 'tab'
|
21
|
-
})),
|
22
|
-
numbers,
|
23
|
-
path,
|
24
|
-
relationships,
|
25
|
-
table,
|
26
|
-
texts
|
27
|
-
});
|
28
|
-
}
|
29
|
-
if (field.type === 'collapsible' || field.type === 'row' || field.type === 'tab' && !('name' in field)) {
|
30
|
-
traverseFields({
|
31
|
-
adapter,
|
32
|
-
blocks,
|
33
|
-
config,
|
34
|
-
dataRef,
|
35
|
-
deletions,
|
36
|
-
fieldPrefix,
|
37
|
-
fields: field.fields,
|
38
|
-
numbers,
|
39
|
-
path,
|
40
|
-
relationships,
|
41
|
-
table,
|
42
|
-
texts
|
43
|
-
});
|
44
|
-
}
|
45
|
-
if (fieldAffectsData(field)) {
|
46
|
-
const fieldName = `${fieldPrefix || ''}${field.name}`;
|
47
|
-
const fieldData = table[fieldName];
|
48
|
-
const localizedFieldData = {};
|
49
|
-
const valuesToTransform = [];
|
50
|
-
if (fieldPrefix) {
|
51
|
-
deletions.push(()=>delete table[fieldName]);
|
52
|
-
}
|
53
|
-
if (field.type === 'array') {
|
54
|
-
if (Array.isArray(fieldData)) {
|
55
|
-
if (field.localized) {
|
56
|
-
result[field.name] = fieldData.reduce((arrayResult, row)=>{
|
57
|
-
if (typeof row._locale === 'string') {
|
58
|
-
if (!arrayResult[row._locale]) arrayResult[row._locale] = [];
|
59
|
-
const locale = row._locale;
|
60
|
-
const data = {};
|
61
|
-
delete row._locale;
|
62
|
-
if (row._uuid) {
|
63
|
-
row.id = row._uuid;
|
64
|
-
delete row._uuid;
|
65
|
-
}
|
66
|
-
const rowResult = traverseFields({
|
67
|
-
adapter,
|
68
|
-
blocks,
|
69
|
-
config,
|
70
|
-
dataRef: data,
|
71
|
-
deletions,
|
72
|
-
fieldPrefix: '',
|
73
|
-
fields: field.fields,
|
74
|
-
numbers,
|
75
|
-
path: `${sanitizedPath}${field.name}.${row._order - 1}`,
|
76
|
-
relationships,
|
77
|
-
table: row,
|
78
|
-
texts
|
79
|
-
});
|
80
|
-
if ('_order' in rowResult) {
|
81
|
-
delete rowResult._order;
|
82
|
-
}
|
83
|
-
arrayResult[locale].push(rowResult);
|
84
|
-
}
|
85
|
-
return arrayResult;
|
86
|
-
}, {});
|
87
|
-
} else {
|
88
|
-
result[field.name] = fieldData.map((row, i)=>{
|
89
|
-
if (row._uuid) {
|
90
|
-
row.id = row._uuid;
|
91
|
-
delete row._uuid;
|
92
|
-
}
|
93
|
-
if ('_order' in row) {
|
94
|
-
delete row._order;
|
95
|
-
}
|
96
|
-
return traverseFields({
|
97
|
-
adapter,
|
98
|
-
blocks,
|
99
|
-
config,
|
100
|
-
dataRef: row,
|
101
|
-
deletions,
|
102
|
-
fieldPrefix: '',
|
103
|
-
fields: field.fields,
|
104
|
-
numbers,
|
105
|
-
path: `${sanitizedPath}${field.name}.${i}`,
|
106
|
-
relationships,
|
107
|
-
table: row,
|
108
|
-
texts
|
109
|
-
});
|
110
|
-
});
|
111
|
-
}
|
112
|
-
}
|
113
|
-
return result;
|
114
|
-
}
|
115
|
-
if (field.type === 'blocks') {
|
116
|
-
const blockFieldPath = `${sanitizedPath}${field.name}`;
|
117
|
-
if (Array.isArray(blocks[blockFieldPath])) {
|
118
|
-
if (field.localized) {
|
119
|
-
result[field.name] = {};
|
120
|
-
blocks[blockFieldPath].forEach((row)=>{
|
121
|
-
if (row._uuid) {
|
122
|
-
row.id = row._uuid;
|
123
|
-
delete row._uuid;
|
124
|
-
}
|
125
|
-
if (typeof row._locale === 'string') {
|
126
|
-
if (!result[field.name][row._locale]) result[field.name][row._locale] = [];
|
127
|
-
result[field.name][row._locale].push(row);
|
128
|
-
delete row._locale;
|
129
|
-
}
|
130
|
-
});
|
131
|
-
Object.entries(result[field.name]).forEach(([locale, localizedBlocks])=>{
|
132
|
-
result[field.name][locale] = localizedBlocks.map((row)=>{
|
133
|
-
const block = field.blocks.find(({ slug })=>slug === row.blockType);
|
134
|
-
if (block) {
|
135
|
-
const blockResult = traverseFields({
|
136
|
-
adapter,
|
137
|
-
blocks,
|
138
|
-
config,
|
139
|
-
dataRef: row,
|
140
|
-
deletions,
|
141
|
-
fieldPrefix: '',
|
142
|
-
fields: block.fields,
|
143
|
-
numbers,
|
144
|
-
path: `${blockFieldPath}.${row._order - 1}`,
|
145
|
-
relationships,
|
146
|
-
table: row,
|
147
|
-
texts
|
148
|
-
});
|
149
|
-
delete blockResult._order;
|
150
|
-
return blockResult;
|
151
|
-
}
|
152
|
-
return {};
|
153
|
-
});
|
154
|
-
});
|
155
|
-
} else {
|
156
|
-
result[field.name] = blocks[blockFieldPath].map((row, i)=>{
|
157
|
-
delete row._order;
|
158
|
-
if (row._uuid) {
|
159
|
-
row.id = row._uuid;
|
160
|
-
delete row._uuid;
|
161
|
-
}
|
162
|
-
const block = field.blocks.find(({ slug })=>slug === row.blockType);
|
163
|
-
if (block) {
|
164
|
-
return traverseFields({
|
165
|
-
adapter,
|
166
|
-
blocks,
|
167
|
-
config,
|
168
|
-
dataRef: row,
|
169
|
-
deletions,
|
170
|
-
fieldPrefix: '',
|
171
|
-
fields: block.fields,
|
172
|
-
numbers,
|
173
|
-
path: `${blockFieldPath}.${i}`,
|
174
|
-
relationships,
|
175
|
-
table: row,
|
176
|
-
texts
|
177
|
-
});
|
178
|
-
}
|
179
|
-
return {};
|
180
|
-
});
|
181
|
-
}
|
182
|
-
}
|
183
|
-
return result;
|
184
|
-
}
|
185
|
-
if (field.type === 'relationship' || field.type === 'upload') {
|
186
|
-
if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {
|
187
|
-
if (field.localized && config.localization && config.localization.locales && Array.isArray(table?._locales)) {
|
188
|
-
table._locales.forEach((localeRow)=>{
|
189
|
-
result[field.name] = {
|
190
|
-
[localeRow._locale]: localeRow[fieldName]
|
191
|
-
};
|
192
|
-
});
|
193
|
-
} else {
|
194
|
-
valuesToTransform.push({
|
195
|
-
ref: result,
|
196
|
-
table
|
197
|
-
});
|
198
|
-
}
|
199
|
-
} else {
|
200
|
-
const relationPathMatch = relationships[`${sanitizedPath}${field.name}`];
|
201
|
-
if (!relationPathMatch) {
|
202
|
-
if ('hasMany' in field && field.hasMany) {
|
203
|
-
if (field.localized && config.localization && config.localization.locales) {
|
204
|
-
result[field.name] = {
|
205
|
-
[config.localization.defaultLocale]: []
|
206
|
-
};
|
207
|
-
} else {
|
208
|
-
result[field.name] = [];
|
209
|
-
}
|
210
|
-
}
|
211
|
-
return result;
|
212
|
-
}
|
213
|
-
if (field.localized) {
|
214
|
-
result[field.name] = {};
|
215
|
-
const relationsByLocale = {};
|
216
|
-
relationPathMatch.forEach((row)=>{
|
217
|
-
if (typeof row.locale === 'string') {
|
218
|
-
if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = [];
|
219
|
-
relationsByLocale[row.locale].push(row);
|
220
|
-
}
|
221
|
-
});
|
222
|
-
Object.entries(relationsByLocale).forEach(([locale, relations])=>{
|
223
|
-
transformRelationship({
|
224
|
-
field,
|
225
|
-
locale,
|
226
|
-
ref: result,
|
227
|
-
relations
|
228
|
-
});
|
229
|
-
});
|
230
|
-
} else {
|
231
|
-
transformRelationship({
|
232
|
-
field,
|
233
|
-
ref: result,
|
234
|
-
relations: relationPathMatch
|
235
|
-
});
|
236
|
-
}
|
237
|
-
return result;
|
238
|
-
}
|
239
|
-
}
|
240
|
-
if (field.type === 'text' && field?.hasMany) {
|
241
|
-
const textPathMatch = texts[`${sanitizedPath}${field.name}`];
|
242
|
-
if (!textPathMatch) return result;
|
243
|
-
if (field.localized) {
|
244
|
-
result[field.name] = {};
|
245
|
-
const textsByLocale = {};
|
246
|
-
textPathMatch.forEach((row)=>{
|
247
|
-
if (typeof row.locale === 'string') {
|
248
|
-
if (!textsByLocale[row.locale]) textsByLocale[row.locale] = [];
|
249
|
-
textsByLocale[row.locale].push(row);
|
250
|
-
}
|
251
|
-
});
|
252
|
-
Object.entries(textsByLocale).forEach(([locale, texts])=>{
|
253
|
-
transformHasManyText({
|
254
|
-
field,
|
255
|
-
locale,
|
256
|
-
ref: result,
|
257
|
-
textRows: texts
|
258
|
-
});
|
259
|
-
});
|
260
|
-
} else {
|
261
|
-
transformHasManyText({
|
262
|
-
field,
|
263
|
-
ref: result,
|
264
|
-
textRows: textPathMatch
|
265
|
-
});
|
266
|
-
}
|
267
|
-
return result;
|
268
|
-
}
|
269
|
-
if (field.type === 'number' && field.hasMany) {
|
270
|
-
const numberPathMatch = numbers[`${sanitizedPath}${field.name}`];
|
271
|
-
if (!numberPathMatch) return result;
|
272
|
-
if (field.localized) {
|
273
|
-
result[field.name] = {};
|
274
|
-
const numbersByLocale = {};
|
275
|
-
numberPathMatch.forEach((row)=>{
|
276
|
-
if (typeof row.locale === 'string') {
|
277
|
-
if (!numbersByLocale[row.locale]) numbersByLocale[row.locale] = [];
|
278
|
-
numbersByLocale[row.locale].push(row);
|
279
|
-
}
|
280
|
-
});
|
281
|
-
Object.entries(numbersByLocale).forEach(([locale, numbers])=>{
|
282
|
-
transformHasManyNumber({
|
283
|
-
field,
|
284
|
-
locale,
|
285
|
-
numberRows: numbers,
|
286
|
-
ref: result
|
287
|
-
});
|
288
|
-
});
|
289
|
-
} else {
|
290
|
-
transformHasManyNumber({
|
291
|
-
field,
|
292
|
-
numberRows: numberPathMatch,
|
293
|
-
ref: result
|
294
|
-
});
|
295
|
-
}
|
296
|
-
return result;
|
297
|
-
}
|
298
|
-
if (field.type === 'select' && field.hasMany) {
|
299
|
-
if (Array.isArray(fieldData)) {
|
300
|
-
if (field.localized) {
|
301
|
-
result[field.name] = fieldData.reduce((selectResult, row)=>{
|
302
|
-
if (typeof row.locale === 'string') {
|
303
|
-
if (!selectResult[row.locale]) selectResult[row.locale] = [];
|
304
|
-
selectResult[row.locale].push(row.value);
|
305
|
-
}
|
306
|
-
return selectResult;
|
307
|
-
}, {});
|
308
|
-
} else {
|
309
|
-
result[field.name] = fieldData.map(({ value })=>value);
|
310
|
-
}
|
311
|
-
}
|
312
|
-
return result;
|
313
|
-
}
|
314
|
-
if (field.localized && Array.isArray(table._locales)) {
|
315
|
-
table._locales.forEach((localeRow)=>{
|
316
|
-
valuesToTransform.push({
|
317
|
-
ref: localizedFieldData,
|
318
|
-
table: localeRow
|
319
|
-
});
|
320
|
-
});
|
321
|
-
} else {
|
322
|
-
valuesToTransform.push({
|
323
|
-
ref: result,
|
324
|
-
table
|
325
|
-
});
|
326
|
-
}
|
327
|
-
valuesToTransform.forEach(({ ref, table })=>{
|
328
|
-
const fieldData = table[`${fieldPrefix || ''}${field.name}`];
|
329
|
-
const locale = table?._locale;
|
330
|
-
let val = fieldData;
|
331
|
-
switch(field.type){
|
332
|
-
case 'tab':
|
333
|
-
case 'group':
|
334
|
-
{
|
335
|
-
const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`;
|
336
|
-
if (field.localized) {
|
337
|
-
if (typeof locale === 'string' && !ref[locale]) {
|
338
|
-
ref[locale] = {};
|
339
|
-
delete table._locale;
|
340
|
-
}
|
341
|
-
Object.entries(ref).forEach(([groupLocale, groupLocaleData])=>{
|
342
|
-
ref[groupLocale] = traverseFields({
|
343
|
-
adapter,
|
344
|
-
blocks,
|
345
|
-
config,
|
346
|
-
dataRef: groupLocaleData,
|
347
|
-
deletions,
|
348
|
-
fieldPrefix: groupFieldPrefix,
|
349
|
-
fields: field.fields,
|
350
|
-
numbers,
|
351
|
-
path: `${sanitizedPath}${field.name}`,
|
352
|
-
relationships,
|
353
|
-
table,
|
354
|
-
texts
|
355
|
-
});
|
356
|
-
});
|
357
|
-
if ('_order' in ref) {
|
358
|
-
delete ref._order;
|
359
|
-
}
|
360
|
-
} else {
|
361
|
-
const groupData = {};
|
362
|
-
ref[field.name] = traverseFields({
|
363
|
-
adapter,
|
364
|
-
blocks,
|
365
|
-
config,
|
366
|
-
dataRef: groupData,
|
367
|
-
deletions,
|
368
|
-
fieldPrefix: groupFieldPrefix,
|
369
|
-
fields: field.fields,
|
370
|
-
numbers,
|
371
|
-
path: `${sanitizedPath}${field.name}`,
|
372
|
-
relationships,
|
373
|
-
table,
|
374
|
-
texts
|
375
|
-
});
|
376
|
-
if ('_order' in ref) {
|
377
|
-
delete ref._order;
|
378
|
-
}
|
379
|
-
}
|
380
|
-
return;
|
381
|
-
}
|
382
|
-
case 'text':
|
383
|
-
{
|
384
|
-
if (typeof fieldData === 'string') {
|
385
|
-
val = String(fieldData);
|
386
|
-
}
|
387
|
-
break;
|
388
|
-
}
|
389
|
-
case 'number':
|
390
|
-
{
|
391
|
-
if (typeof fieldData === 'string') {
|
392
|
-
val = Number.parseFloat(fieldData);
|
393
|
-
}
|
394
|
-
break;
|
395
|
-
}
|
396
|
-
case 'date':
|
397
|
-
{
|
398
|
-
if (typeof fieldData === 'string') {
|
399
|
-
val = new Date(fieldData).toISOString();
|
400
|
-
}
|
401
|
-
break;
|
402
|
-
}
|
403
|
-
case 'relationship':
|
404
|
-
case 'upload':
|
405
|
-
{
|
406
|
-
if (val && typeof field.relationTo === 'string' && adapter.payload.collections[field.relationTo].customIDType === 'number') {
|
407
|
-
val = Number(val);
|
408
|
-
}
|
409
|
-
break;
|
410
|
-
}
|
411
|
-
default:
|
412
|
-
{
|
413
|
-
break;
|
414
|
-
}
|
415
|
-
}
|
416
|
-
if (typeof locale === 'string') {
|
417
|
-
ref[locale] = val;
|
418
|
-
} else {
|
419
|
-
result[field.name] = val;
|
420
|
-
}
|
421
|
-
});
|
422
|
-
if (Object.keys(localizedFieldData).length > 0) {
|
423
|
-
result[field.name] = localizedFieldData;
|
424
|
-
}
|
425
|
-
return result;
|
426
|
-
}
|
427
|
-
return result;
|
428
|
-
}, dataRef);
|
429
|
-
if (Array.isArray(table._locales)) {
|
430
|
-
deletions.push(()=>delete table._locales);
|
431
|
-
}
|
432
|
-
return formatted;
|
433
|
-
};
|
434
|
-
|
435
|
-
//# sourceMappingURL=traverseFields.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field, TabAsField } from 'payload'\nimport type { SanitizedConfig } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { BlocksMap } from '../../utilities/createBlocksMap.js'\n\nimport { transformHasManyNumber } from './hasManyNumber.js'\nimport { transformHasManyText } from './hasManyText.js'\nimport { transformRelationship } from './relationship.js'\n\ntype TraverseFieldsArgs = {\n /**\n * The DB adapter\n */\n adapter: PostgresAdapter\n /**\n * Pre-formatted blocks map\n */\n blocks: BlocksMap\n /**\n * The full Payload config\n */\n config: SanitizedConfig\n /**\n * The data reference to be mutated within this recursive function\n */\n dataRef: Record<string, unknown>\n /**\n * Data that needs to be removed from the result after all fields have populated\n */\n deletions: (() => void)[]\n /**\n * Column prefix can be built up by group and named tab fields\n */\n fieldPrefix: string\n /**\n * An array of Payload fields to traverse\n */\n fields: (Field | TabAsField)[]\n /**\n * All hasMany number fields, as returned by Drizzle, keyed on an object by field path\n */\n numbers: Record<string, Record<string, unknown>[]>\n /**\n * The current field path (in dot notation), used to merge in relationships\n */\n path: string\n /**\n * All related documents, as returned by Drizzle, keyed on an object by field path\n */\n relationships: Record<string, Record<string, unknown>[]>\n /**\n * Data structure representing the nearest table from db\n */\n table: Record<string, unknown>\n /**\n * All hasMany text fields, as returned by Drizzle, keyed on an object by field path\n */\n texts: Record<string, Record<string, unknown>[]>\n}\n\n// Traverse fields recursively, transforming data\n// for each field type into required Payload shape\nexport const traverseFields = <T extends Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n\n const formatted = fields.reduce((result, field) => {\n if (field.type === 'tabs') {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (\n field.type === 'collapsible' ||\n field.type === 'row' ||\n (field.type === 'tab' && !('name' in field))\n ) {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (fieldAffectsData(field)) {\n const fieldName = `${fieldPrefix || ''}${field.name}`\n const fieldData = table[fieldName]\n const localizedFieldData = {}\n const valuesToTransform: {\n ref: Record<string, unknown>\n table: Record<string, unknown>\n }[] = []\n\n if (fieldPrefix) {\n deletions.push(() => delete table[fieldName])\n }\n\n if (field.type === 'array') {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((arrayResult, row) => {\n if (typeof row._locale === 'string') {\n if (!arrayResult[row._locale]) arrayResult[row._locale] = []\n const locale = row._locale\n const data = {}\n delete row._locale\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n const rowResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: data,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n if ('_order' in rowResult) {\n delete rowResult._order\n }\n\n arrayResult[locale].push(rowResult)\n }\n\n return arrayResult\n }, {})\n } else {\n result[field.name] = fieldData.map((row, i) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if ('_order' in row) {\n delete row._order\n }\n\n return traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n texts,\n })\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks') {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n\n if (Array.isArray(blocks[blockFieldPath])) {\n if (field.localized) {\n result[field.name] = {}\n\n blocks[blockFieldPath].forEach((row) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n if (typeof row._locale === 'string') {\n if (!result[field.name][row._locale]) result[field.name][row._locale] = []\n result[field.name][row._locale].push(row)\n delete row._locale\n }\n })\n\n Object.entries(result[field.name]).forEach(([locale, localizedBlocks]) => {\n result[field.name][locale] = localizedBlocks.map((row) => {\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n const blockResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n result[field.name] = blocks[blockFieldPath].map((row, i) => {\n delete row._order\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n return traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n texts,\n })\n }\n\n return {}\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {\n if (\n field.localized &&\n config.localization &&\n config.localization.locales &&\n Array.isArray(table?._locales)\n ) {\n table._locales.forEach((localeRow) => {\n result[field.name] = { [localeRow._locale]: localeRow[fieldName] }\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n } else {\n const relationPathMatch = relationships[`${sanitizedPath}${field.name}`]\n if (!relationPathMatch) {\n if ('hasMany' in field && field.hasMany) {\n if (field.localized && config.localization && config.localization.locales) {\n result[field.name] = {\n [config.localization.defaultLocale]: [],\n }\n } else {\n result[field.name] = []\n }\n }\n\n return result\n }\n\n if (field.localized) {\n result[field.name] = {}\n const relationsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n relationPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = []\n relationsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(relationsByLocale).forEach(([locale, relations]) => {\n transformRelationship({\n field,\n locale,\n ref: result,\n relations,\n })\n })\n } else {\n transformRelationship({\n field,\n ref: result,\n relations: relationPathMatch,\n })\n }\n return result\n }\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const textsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n textPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!textsByLocale[row.locale]) textsByLocale[row.locale] = []\n textsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(textsByLocale).forEach(([locale, texts]) => {\n transformHasManyText({\n field,\n locale,\n ref: result,\n textRows: texts,\n })\n })\n } else {\n transformHasManyText({\n field,\n ref: result,\n textRows: textPathMatch,\n })\n }\n\n return result\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPathMatch = numbers[`${sanitizedPath}${field.name}`]\n if (!numberPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const numbersByLocale: Record<string, Record<string, unknown>[]> = {}\n\n numberPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!numbersByLocale[row.locale]) numbersByLocale[row.locale] = []\n numbersByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(numbersByLocale).forEach(([locale, numbers]) => {\n transformHasManyNumber({\n field,\n locale,\n numberRows: numbers,\n ref: result,\n })\n })\n } else {\n transformHasManyNumber({\n field,\n numberRows: numberPathMatch,\n ref: result,\n })\n }\n\n return result\n }\n\n if (field.type === 'select' && field.hasMany) {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((selectResult, row) => {\n if (typeof row.locale === 'string') {\n if (!selectResult[row.locale]) selectResult[row.locale] = []\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n result[field.name] = fieldData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (field.localized && Array.isArray(table._locales)) {\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({ ref: localizedFieldData, table: localeRow })\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n\n valuesToTransform.forEach(({ ref, table }) => {\n const fieldData = table[`${fieldPrefix || ''}${field.name}`]\n const locale = table?._locale\n let val = fieldData\n\n switch (field.type) {\n case 'tab':\n case 'group': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n\n if (field.localized) {\n if (typeof locale === 'string' && !ref[locale]) {\n ref[locale] = {}\n delete table._locale\n }\n\n Object.entries(ref).forEach(([groupLocale, groupLocaleData]) => {\n ref[groupLocale] = traverseFields<Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef: groupLocaleData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n })\n })\n if ('_order' in ref) {\n delete ref._order\n }\n } else {\n const groupData = {}\n\n ref[field.name] = traverseFields<Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef: groupData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n })\n if ('_order' in ref) {\n delete ref._order\n }\n }\n\n return\n }\n\n case 'text': {\n if (typeof fieldData === 'string') {\n val = String(fieldData)\n }\n\n break\n }\n\n case 'number': {\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n break\n }\n\n case 'date': {\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n val &&\n typeof field.relationTo === 'string' &&\n adapter.payload.collections[field.relationTo].customIDType === 'number'\n ) {\n val = Number(val)\n }\n\n break\n }\n\n default: {\n break\n }\n }\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n })\n\n if (Object.keys(localizedFieldData).length > 0) {\n result[field.name] = localizedFieldData\n }\n\n return result\n }\n\n return result\n }, dataRef)\n\n if (Array.isArray(table._locales)) {\n deletions.push(() => delete table._locales)\n }\n\n return formatted as T\n}\n"],"names":["fieldAffectsData","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","dataRef","deletions","fieldPrefix","fields","numbers","path","relationships","table","texts","sanitizedPath","formatted","reduce","result","field","type","tabs","map","tab","fieldName","name","fieldData","localizedFieldData","valuesToTransform","push","Array","isArray","localized","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","_order","i","blockFieldPath","forEach","Object","entries","localizedBlocks","block","find","slug","blockType","blockResult","relationTo","hasMany","localization","locales","_locales","localeRow","ref","relationPathMatch","defaultLocale","relationsByLocale","relations","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","val","groupFieldPrefix","groupLocale","groupLocaleData","groupData","String","Number","parseFloat","Date","toISOString","payload","collections","customIDType","keys","length"],"mappings":"AAAA,oCAAoC,GAIpC,SAASA,gBAAgB,QAAQ,iBAAgB;AAKjD,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,qBAAqB,QAAQ,oBAAmB;AAqDzD,iDAAiD;AACjD,kDAAkD;AAClD,OAAO,MAAMC,iBAAiB,CAAoC,EAChEC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACc;IACnB,MAAMC,gBAAgBJ,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAGA;IAE1C,MAAMK,YAAYP,OAAOQ,MAAM,CAAC,CAACC,QAAQC;QACvC,IAAIA,MAAMC,IAAI,KAAK,QAAQ;YACzBlB,eAAe;gBACbC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,QAAQU,MAAME,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;wBAAE,GAAGA,GAAG;wBAAEH,MAAM;oBAAM,CAAA;gBACvDV;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;QAEA,IACEK,MAAMC,IAAI,KAAK,iBACfD,MAAMC,IAAI,KAAK,SACdD,MAAMC,IAAI,KAAK,SAAS,CA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,UAAU;gCACjC8C,MAAM,IAAIQ,KAAKtD,WAAWuD,WAAW;4BACvC;4BAEA;wBACF;oBAEA,KAAK;oBACL,KAAK;wBAAU;4BACb,IACET,OACA,OAAOrD,MAAMkC,UAAU,KAAK,YAC5BlD,QAAQ+E,OAAO,CAACC,WAAW,CAAChE,MAAMkC,UAAU,CAAC,CAAC+B,YAAY,KAAK,UAC/D;gCACAZ,MAAMM,OAAON;4BACf;4BAEA;wBACF;oBAEA;wBAAS;4BACP;wBACF;gBACF;gBACA,IAAI,OAAOpC,WAAW,UAAU;oBAC9BuB,GAAG,CAACvB,OAAO,GAAGoC;gBAChB,OAAO;oBACLtD,MAAM,CAACC,MAAMM,IAAI,CAAC,GAAG+C;gBACvB;YACF;YAEA,IAAI3B,OAAOwC,IAAI,CAAC1D,oBAAoB2D,MAAM,GAAG,GAAG;gBAC9CpE,MAAM,CAACC,MAAMM,IAAI,CAAC,GAAGE;YACvB;YAEA,OAAOT;QACT;QAEA,OAAOA;IACT,GAAGZ;IAEH,IAAIwB,MAAMC,OAAO,CAAClB,MAAM4C,QAAQ,GAAG;QACjClD,UAAUsB,IAAI,CAAC,IAAM,OAAOhB,MAAM4C,QAAQ;IAC5C;IAEA,OAAOzC;AACT,EAAC"}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import type { ArrayField } from 'payload';
|
2
|
-
import type { PostgresAdapter } from '../../types.js';
|
3
|
-
import type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js';
|
4
|
-
type Args = {
|
5
|
-
adapter: PostgresAdapter;
|
6
|
-
arrayTableName: string;
|
7
|
-
baseTableName: string;
|
8
|
-
blocks: {
|
9
|
-
[blockType: string]: BlockRowToInsert[];
|
10
|
-
};
|
11
|
-
blocksToDelete: Set<string>;
|
12
|
-
data: unknown;
|
13
|
-
field: ArrayField;
|
14
|
-
locale?: string;
|
15
|
-
numbers: Record<string, unknown>[];
|
16
|
-
path: string;
|
17
|
-
relationships: Record<string, unknown>[];
|
18
|
-
relationshipsToDelete: RelationshipToDelete[];
|
19
|
-
selects: {
|
20
|
-
[tableName: string]: Record<string, unknown>[];
|
21
|
-
};
|
22
|
-
texts: Record<string, unknown>[];
|
23
|
-
};
|
24
|
-
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, }: Args) => ArrayRowToInsert[];
|
25
|
-
export {};
|
26
|
-
//# sourceMappingURL=array.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/transform/write/array.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAK1F,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAC/C,CAAA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,cAAc,kKAexB,IAAI,uBA6DN,CAAA"}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
2
|
-
import { traverseFields } from './traverseFields.js';
|
3
|
-
export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts })=>{
|
4
|
-
const newRows = [];
|
5
|
-
const hasUUID = adapter.tables[arrayTableName]._uuid;
|
6
|
-
if (isArrayOfRows(data)) {
|
7
|
-
data.forEach((arrayRow, i)=>{
|
8
|
-
const newRow = {
|
9
|
-
arrays: {},
|
10
|
-
locales: {},
|
11
|
-
row: {
|
12
|
-
_order: i + 1
|
13
|
-
}
|
14
|
-
};
|
15
|
-
// If we have declared a _uuid field on arrays,
|
16
|
-
// that means the ID has to be unique,
|
17
|
-
// and our ids within arrays are not unique.
|
18
|
-
// So move the ID to a uuid field for storage
|
19
|
-
// and allow the database to generate a serial id automatically
|
20
|
-
if (hasUUID) {
|
21
|
-
newRow.row._uuid = arrayRow.id;
|
22
|
-
delete arrayRow.id;
|
23
|
-
}
|
24
|
-
if (locale) {
|
25
|
-
newRow.locales[locale] = {
|
26
|
-
_locale: locale
|
27
|
-
};
|
28
|
-
}
|
29
|
-
if (field.localized) {
|
30
|
-
newRow.row._locale = locale;
|
31
|
-
}
|
32
|
-
traverseFields({
|
33
|
-
adapter,
|
34
|
-
arrays: newRow.arrays,
|
35
|
-
baseTableName,
|
36
|
-
blocks,
|
37
|
-
blocksToDelete,
|
38
|
-
columnPrefix: '',
|
39
|
-
data: arrayRow,
|
40
|
-
fieldPrefix: '',
|
41
|
-
fields: field.fields,
|
42
|
-
locales: newRow.locales,
|
43
|
-
numbers,
|
44
|
-
parentTableName: arrayTableName,
|
45
|
-
path: `${path || ''}${field.name}.${i}.`,
|
46
|
-
relationships,
|
47
|
-
relationshipsToDelete,
|
48
|
-
row: newRow.row,
|
49
|
-
selects,
|
50
|
-
texts
|
51
|
-
});
|
52
|
-
newRows.push(newRow);
|
53
|
-
});
|
54
|
-
}
|
55
|
-
return newRows;
|
56
|
-
};
|
57
|
-
|
58
|
-
//# sourceMappingURL=array.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/array.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { ArrayField } from 'payload'\n\nimport type { PostgresAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: PostgresAdapter\n arrayTableName: string\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n data: unknown\n field: ArrayField\n locale?: string\n numbers: Record<string, unknown>[]\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n}\n\nexport const transformArray = ({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n}: Args) => {\n const newRows: ArrayRowToInsert[] = []\n\n const hasUUID = adapter.tables[arrayTableName]._uuid\n\n if (isArrayOfRows(data)) {\n data.forEach((arrayRow, i) => {\n const newRow: ArrayRowToInsert = {\n arrays: {},\n locales: {},\n row: {\n _order: i + 1,\n },\n }\n\n // If we have declared a _uuid field on arrays,\n // that means the ID has to be unique,\n // and our ids within arrays are not unique.\n // So move the ID to a uuid field for storage\n // and allow the database to generate a serial id automatically\n if (hasUUID) {\n newRow.row._uuid = arrayRow.id\n delete arrayRow.id\n }\n\n if (locale) {\n newRow.locales[locale] = {\n _locale: locale,\n }\n }\n\n if (field.localized) {\n newRow.row._locale = locale\n }\n\n traverseFields({\n adapter,\n arrays: newRow.arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: '',\n data: arrayRow,\n fieldPrefix: '',\n fields: field.fields,\n locales: newRow.locales,\n numbers,\n parentTableName: arrayTableName,\n path: `${path || ''}${field.name}.${i}.`,\n relationships,\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n })\n\n newRows.push(newRow)\n })\n }\n\n return newRows\n}\n"],"names":["isArrayOfRows","traverseFields","transformArray","adapter","arrayTableName","baseTableName","blocks","blocksToDelete","data","field","locale","numbers","path","relationships","relationshipsToDelete","selects","texts","newRows","hasUUID","tables","_uuid","forEach","arrayRow","i","newRow","arrays","locales","row","_order","id","_locale","localized","columnPrefix","fieldPrefix","fields","parentTableName","name","push"],"mappings":"AAAA,oCAAoC,GAMpC,SAASA,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AAuBpD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,aAAa,EACbC,qBAAqB,EACrBC,OAAO,EACPC,KAAK,EACA;IACL,MAAMC,UAA8B,EAAE;IAEtC,MAAMC,UAAUf,QAAQgB,MAAM,CAACf,eAAe,CAACgB,KAAK;IAEpD,IAAIpB,cAAcQ,OAAO;QACvBA,KAAKa,OAAO,CAAC,CAACC,UAAUC;YACtB,MAAMC,SAA2B;gBAC/BC,QAAQ,CAAC;gBACTC,SAAS,CAAC;gBACVC,KAAK;oBACHC,QAAQL,IAAI;gBACd;YACF;YAEA,+CAA+C;YAC/C,sCAAsC;YACtC,4CAA4C;YAC5C,6CAA6C;YAC7C,+DAA+D;YAC/D,IAAIL,SAAS;gBACXM,OAAOG,GAAG,CAACP,KAAK,GAAGE,SAASO,EAAE;gBAC9B,OAAOP,SAASO,EAAE;YACpB;YAEA,IAAInB,QAAQ;gBACVc,OAAOE,OAAO,CAAChB,OAAO,GAAG;oBACvBoB,SAASpB;gBACX;YACF;YAEA,IAAID,MAAMsB,SAAS,EAAE;gBACnBP,OAAOG,GAAG,CAACG,OAAO,GAAGpB;YACvB;YAEAT,eAAe;gBACbE;gBACAsB,QAAQD,OAAOC,MAAM;gBACrBpB;gBACAC;gBACAC;gBACAyB,cAAc;gBACdxB,MAAMc;gBACNW,aAAa;gBACbC,QAAQzB,MAAMyB,MAAM;gBACpBR,SAASF,OAAOE,OAAO;gBACvBf;gBACAwB,iBAAiB/B;gBACjBQ,MAAM,CAAC,EAAEA,QAAQ,GAAG,EAAEH,MAAM2B,IAAI,CAAC,CAAC,EAAEb,EAAE,CAAC,CAAC;gBACxCV;gBACAC;gBACAa,KAAKH,OAAOG,GAAG;gBACfZ;gBACAC;YACF;YAEAC,QAAQoB,IAAI,CAACb;QACf;IACF;IAEA,OAAOP;AACT,EAAC"}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import type { BlockField } from 'payload';
|
2
|
-
import type { PostgresAdapter } from '../../types.js';
|
3
|
-
import type { BlockRowToInsert, RelationshipToDelete } from './types.js';
|
4
|
-
type Args = {
|
5
|
-
adapter: PostgresAdapter;
|
6
|
-
baseTableName: string;
|
7
|
-
blocks: {
|
8
|
-
[blockType: string]: BlockRowToInsert[];
|
9
|
-
};
|
10
|
-
blocksToDelete: Set<string>;
|
11
|
-
data: Record<string, unknown>[];
|
12
|
-
field: BlockField;
|
13
|
-
locale?: string;
|
14
|
-
numbers: Record<string, unknown>[];
|
15
|
-
path: string;
|
16
|
-
relationships: Record<string, unknown>[];
|
17
|
-
relationshipsToDelete: RelationshipToDelete[];
|
18
|
-
selects: {
|
19
|
-
[tableName: string]: Record<string, unknown>[];
|
20
|
-
};
|
21
|
-
texts: Record<string, unknown>[];
|
22
|
-
};
|
23
|
-
export declare const transformBlocks: ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, }: Args) => void;
|
24
|
-
export {};
|
25
|
-
//# sourceMappingURL=blocks.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/transform/write/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAIxE,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAC/C,CAAA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CACjC,CAAA;AACD,eAAO,MAAM,eAAe,kJAczB,IAAI,SAyDN,CAAA"}
|